Jump to content

Order By Syntax Issue


son
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...