我试图让购物车形成1张桌子,只有1个条件,这是下一个“购物车必须比任何具有相同id_user的订单更新”
SELECT pso.*
FROM lafrips_cart pso
WHERE pso.id_customer > 0
AND pso.date_add > (SELECT MAX(pso2.date_add)
FROM lafrips_orders pso2
WHERE pso2.id_customer < pso.id_customer)
我只是比较两个字段(pso.date_add和ps2.date_add)都是具有相同结构的datetime
答案 0 :(得分:1)
SELECT pso.*
FROM lafrips_cart pso
WHERE
pso.id_customer > 0
AND pso.date_add > (
SELECT MAX(pso2.date_add)
FROM lafrips_orders pso2
WHERE pso2.id_customer = pso.id_customer
)
答案 1 :(得分:0)
你们都说@Siyual和@Sergio“&gt;”是错误,实际上我觉得我像砖一样厚,我可能要睡几个小时
SELECT pso.*
FROM lafrips_cart pso
WHERE
pso.id_customer > 0
AND pso.date_add > (
SELECT MAX(pso2.date_add)
FROM lafrips_orders pso2
WHERE pso2.id_customer **=** pso.id_customer
)
标有** =符号替换