我无法根据同一列中的值更改列值。
如果D244
的“setting_id”的“setting_value”为1
,那么我还需要将“8F60
更改为1
。
以下是数据表settings
| setting_id | setting_value |
| ---------- | ------------- |
| D244 | 1 |
| 8F60 | 0 |
| AD4F | 1 |
我的尝试:
UPDATE settings s, (SELECT DISTINCT setting_id, setting_value FROM settings WHERE setting_value like '1' and setting_id like 'D244') s1
SET s.settingValue = s1.settingValue
WHERE s.settingID like '8F60'
答案 0 :(得分:1)
试试这个 -
UPDATE settings s INNER JOIN settings s1
ON s1.setting_id = s.setting_id
SET s.settingValue = s1.settingValue
WHERE s.settingID like '8F60'
AND s1.setting_id = 'D244'