gpt4 book ai didi

php - 为什么 Mysql order by 不适用于此查询

转载 作者:行者123 更新时间:2023-11-29 12:42:41 25 4
gpt4 key购买 nike

我有这个查询:

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 字段是日期时间

谢谢!

最佳答案

您不能在子查询中使用 order by。尝试使用临时表。

关于php - 为什么 Mysql order by 不适用于此查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25907282/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com