MySQL Order by NULL join
I am trying to do an ORDER BY where I want any strings without an entry in the join table to appear at the bottom of the list and then ordered by name. Simplified tables:
users (id, name) photos (id, filename, user_id)
So far I have:
SELECT name FROM users
LEFT OUTER JOIN photos ON photos.user_id = users.id
ORDER BY *ANSWER HERE*, name DESC
Many thanks.
+2
source to share
2 answers