MySQL query for sorting by multiple date values
I'm creating a PHP script that fetches IDs from a database. The results are sorted by two datetime
values, createdon
and publishon
.
The priority of publishon
is higher than createdon
; however, publishon
may also be NULL
. publishon = null
=> sort by creat开发者_如何学运维edon
.
Can someone help me sort those rows?
ORDER BY IFNULL(PublishOn, CreatedOn), CreatedOn
精彩评论