最佳答案
我试图了解如何更新具有不同值的多行,我只是没有得到它。解决方案无处不在,但对我来说,它看起来很难理解。
例如,对一个查询进行三次更新:
UPDATE table_users
SET cod_user = '622057'
, date = '12082014'
WHERE user_rol = 'student'
AND cod_office = '17389551';
UPDATE table_users
SET cod_user = '2913659'
, date = '12082014'
WHERE user_rol = 'assistant'
AND cod_office = '17389551';
UPDATE table_users
SET cod_user = '6160230'
, date = '12082014'
WHERE user_rol = 'admin'
AND cod_office = '17389551';
我读一个例子,但我真的不明白如何使查询。即:
UPDATE table_to_update
SET cod_user= IF(cod_office = '17389551','622057','2913659','6160230')
,date = IF(cod_office = '17389551','12082014')
WHERE ?? IN (??) ;
我不完全清楚如何做查询,如果有多个条件在哪里和在if条件..有什么想法?