jonw118 Posted August 11, 2010 Share Posted August 11, 2010 Hi there - can anyone lend me a little advise as to what I'm doing wrong here. I have this line: $query=mysql_query("SELECT * FROM gallery a JOIN gallery_image b ON a.id = b.gallery_id where gallery_id=$gallery_id"); I am trying to add an order by statement: order by gallery_image.priority So I created: $query=mysql_query("SELECT * FROM gallery a JOIN gallery_image b ON a.id = b.gallery_id where gallery_id=$gallery_id order by gallery_image.priority"); But, I receive the error (even though there is table called "Gallery Image" and a column called "Priority": Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/***/public_html/***/gallery.php on line 5 select: Unknown column 'gallery_image.priority' in 'order clause' Quote Link to comment Share on other sites More sharing options...
bh Posted August 11, 2010 Share Posted August 11, 2010 Maybe becouse you use an alias... ? $query=mysql_query("SELECT * FROM gallery a JOIN gallery_image b ON a.id = b.gallery_id where gallery_id=$gallery_id order by b.priority"); Quote Link to comment Share on other sites More sharing options...
aeroswat Posted August 11, 2010 Share Posted August 11, 2010 That doesn't seem like good practice to not use the AS keyword Quote Link to comment Share on other sites More sharing options...
TOA Posted August 11, 2010 Share Posted August 11, 2010 Try telling it how to order by -- ASC or DESC Quote Link to comment Share on other sites More sharing options...
aeroswat Posted August 11, 2010 Share Posted August 11, 2010 Try telling it how to order by -- ASC or DESC Won't matter. It defaults to Ascending 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.