Jump to content

Order By Syntax Issue


son

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...