Reputation: 952
I have this query:
SELECT *
FROM (
SELECT p.id, product, unique_name, price, old_price, category_id, added_date
FROM products p, products_to_categories ptc, products_to_adverts pta
WHERE p.id=ptc.product_id AND (expire_date > now() OR expire_date=0)
AND p.id=pta.product_id AND p.active=1 AND p.instock=1 AND p.top_product="1"
and p.id not in (58,59,70,88,92,106,107,108,109)
and pta.advert_id not in (1,4,5,6,7,9,13,15,17)
ORDER BY added_date DESC
) as t GROUP BY id LIMIT 0,32
added_date field is datetime
Thanks !
Upvotes: 0
Views: 71
Reputation: 153
You can not use order by like this inside the query .As I think this is wrong.If you can do this using sql CASE
Follow this article.
[http://www.mysqltutorial.org/mysql-case-statement/][1]
Upvotes: 0
Reputation: 311
You cannot use order by in subquery. Try using temporary table instead.
Upvotes: 1