我想更新表格标题' columns_header其中字段等于' c02_Emissions'和field_base要么'车辆'或者' VEHICLE_FP'。我目前的脚本更新了所有' VEHICLE'和' VEHICLE_FP'记录并不关心字段=' c02_Emissions'。这不是我想要的。我能否对如何正确地做到这一点有所帮助?
UPDATE headers
SET columns_header = 'CO2 Emissions'
WHERE field = 'c02_Emissions'
AND field_base = 'VEHICLE'
OR field_base = 'VEHICLE_FP';
答案 0 :(得分:3)
在梳理AND和&OR时,你应该总是使用括号:
UPDATE headers
SET columns_header = 'CO2 Emissions'
WHERE field = 'c02_Emissions'
AND (field_base = 'VEHICLE'
OR field_base = 'VEHICLE_FP');
答案 1 :(得分:2)
你也可以尝试这个
UPDATE headers
SET columns_header = 'CO2 Emissions'
WHERE field = 'c02_Emissions'
AND field_base IN ( 'VEHICLE','VEHICLE_FP');