I am new to MySQL queries, but I have one difficult thing that I cannot figure out how to do this. Is there a way to tell the system "something that meets the X-condition, first of all, if this is normal." For example, in a table postswith fields, (post_id, author_id, timestamp)I know how to do this ...
mysql_query("SELECT * FROM posts ORDER BY timestamp");
But is there a way for certain user messages (say, author_id = 5) to appear at the top of the results, and then sort by timestamp after that? To be clear: I do NOT want to sort by author_id, I just want to highlight messages where author_idthere are 5, and then sort by timestampfor everything else.
Is there any way to do this? I tried,
mysql_query("SELECT * FROM posts ORDER BY author_id = 5, timestamp");
... but it does not work.
source
share