我有这个问题:
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字段是日期时间
谢谢!
答案 0 :(得分:1)
您不能在子查询中使用order by。请尝试使用临时表。
答案 1 :(得分:0)
您不能在查询中使用这样的顺序。我认为这是错误的。如果您可以使用sql CASE
请遵循这篇文章。