我有这个查询:
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
created_date字段是datetime
谢谢 !
您不能在子查询中使用order by。尝试改用临时表。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句