嗨,我有一条更新语句,我试图将meta_key数量的数量从3以上减少到3(meta_value),每执行一次,我就会收到“ 0行受影响”的信息。
UPDATE usermeta
INNER JOIN cov on cov.user_id = usermeta.user_id
SET usermeta.meta_value = '3'
WHERE usermeta.meta_key = 'quantity'
AND usermeta.meta_value > '3'
AND cov.end_date = '2017-05-18'
-- this is the query to see the rows I want changed
SELECT cov.*, usermeta.meta_value
FROM cov
INNER JOIN usermeta
ON cove.user_id = usermeta.user_id
AND meta_key = 'quantity'
WHERE cov.end_date = '2017-05-18' and usermeta.meta_value > 3
ORDER BY end_date
谁能看到我做错了吗?谢谢!
最佳答案
'3'
和3
之间有区别。因此,我将从以下内容开始:
UPDATE usermeta um INNER JOIN
cov
ON cov.user_id = um.user_id
SET um.meta_value = '3'
WHERE um.meta_key = 'quantity' AND
um.meta_value + 0 > 3 AND
cov.end_date = '2017-05-18';