我正在尝试从 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)
我只是比较 2 个字段(pso.date_add 与 ps2.date_add)都是具有相同结构的日期时间
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
)
正如你都说@Siyual和@Sergio">"是错误,实际上我觉得我像砖头一样厚,我可能要多睡几个小时
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
)
标有 ** 的 = 符号已替换