RON_ron Posted September 13, 2012 Share Posted September 13, 2012 ORDER BY is not giving me the expected results. Have I done it correctly? $query = "SELECT * FROM gift_db2 LEFT OUTER JOIN student_db ON gift_db2.category = student_db.name ORDER BY gift_db2.category DESC, gift_db2.grade DESC"; Quote Link to comment Share on other sites More sharing options...
kicken Posted September 13, 2012 Share Posted September 13, 2012 What results are you getting vs what are you expecting to get? Syntactically that line is fine, so your problem probably lies either with the data itself (ie trying to sort numbers stored as VARCHAR), or with how you're processing the results after the query (doing something that alters the order). Quote Link to comment Share on other sites More sharing options...
premiso Posted September 13, 2012 Share Posted September 13, 2012 Are you sure you do not want to group by the category? $query = "SELECT * FROM gift_db2 LEFT OUTER JOIN student_db ON gift_db2.category = student_db.name GROUP BY gift_db2.category ORDER BY gift_db2.grade DESC"; Not knowing how it is not displaying right, just a shot in the dark. Quote Link to comment Share on other sites More sharing options...
fenway Posted September 15, 2012 Share Posted September 15, 2012 What I think you mean to say is that GROUP BY and * is not working. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.