Changing query ordering based on whether a variable equals 1 or 0

fukalotiseryu

New Member
For the query below, I would like to change the way the results are ordered. Right now, the results are ordered by \[code\]ORDER BY most_recent DESC\[/code\]. I would like to keep this ordering, but I would like any row where \[code\]s.topten\[/code\] = 1 to be ordered above rows where \[code\]s.topten\[/code\] = 0.How can I do this?Thanks in advance,John\[code\]$sqlStr = "SELECT s.loginid, s.title, s.url, s.displayurl, s.datesubmitted, l.username, s.submissionid, s.subcheck, s.topten, COUNT(c.commentid) countComments, GREATEST(s.datesubmitted, COALESCE(MAX(c.datecommented), s.datesubmitted)) AS most_recentFROM submission sINNER JOIN login l ON s.loginid = l.loginidLEFT OUTER JOIN comment c ON s.submissionid = c.submissionidGROUP BY s.submissionidORDER BY most_recent DESCLIMIT $offset, $rowsperpage"; \[/code\]
 
Back
Top