I have a database with VARCHAR column url
. I would like to fetch rows so that the ones that have any url
value have priority over other rows, but are ordered by date
row (descending), so ORDER BY 'url' DESC, 'date' DESC
wouldn't work as it would order them alphabetically first. Basically, it would look something like this:
Table:
ID | Url | Date
1 | http://...| 1001
2 | | 1002
3 | | 1003
4 | http://...| 1005
5 | http://...| 1004
Sorted:
ID | Url | Date
4 | http://...| 1005
5 | http://...| 1004
1 | http://...| 1001
3 | | 1003
2 | | 1002
What would be the proper zend framework way (or at least SQL query) to do it?