son Posted October 26, 2009 Share Posted October 26, 2009 I cannot get the ORDER BY syntax right on my query. I have: SELECT product_id, product, img1 FROM products WHERE product_id IN (SELECT product_id FROM productCat WHERE category_id = 9) ORDER BY (SELECT usort FROM productCat) Products should be ordered by the column usort in productCat table. How would I do this correctly?Son Link to comment Share on other sites More sharing options...
justsomeguy Posted October 26, 2009 Share Posted October 26, 2009 You need to join with the productCat table and then you can use it to order. Link to comment Share on other sites More sharing options...
son Posted October 26, 2009 Author Share Posted October 26, 2009 You need to join with the productCat table and then you can use it to order.I did try this before, but had also no luck. PhpMyAdmin says that there is also a mistake in my syntax (near ORDER clause). I had:SELECT products.product_id, product, img1, productCat.usort FROM products, productCat WHERE (products.product_id = productCat.product_id) AND productCat.category_id = 9) ORDER BY productCat.usort Son Link to comment Share on other sites More sharing options...
justsomeguy Posted October 26, 2009 Share Posted October 26, 2009 The parentheses don't match up. Link to comment Share on other sites More sharing options...
son Posted October 26, 2009 Author Share Posted October 26, 2009 The parentheses don't match up.Again, just such a simple thing I overlooked. Sometimes I worry about my concentration;-)Many thanks,Son Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.