update lims_ordtask lo
set lo.cnas = '1'
where exists (select 1
from lims_folders f
where lo.foldersid = f.foldersid
and f.folderno in ('NJ2020MS0095',
'NJ2020MS0094',
'NJ2020MS0093',
'NJ2020MS0092',
'NJ2020MS0091',
'NJ2020MS0090',
'NJ2020MS0089')
and (lo.testno = '色泽' or lo.testno = '滋味、气味' or
lo.testno = '组织状态' or lo.testno = '净含量'))
有两个表:student & city,现在需要取出 city.name 来更新 student.city_name。两表关联条件是 student.city_code=city.code。
update student s, city c
set s.city_name = c.name
where s.city_code = c.code;
也可以试下面的相关子查询:
update student s set city_name = (select name from city where code = s.city_code);
————————————————
版权声明:本文为CSDN博主「宋发元」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u011019141/article/details/80045096
mysql更新字段为“”或 null
//更新为""串
update taxi_driver_info set wechat = '' where driverno = '0440923198101075636'; //更新为null update taxi_driver_info set wechat = null where driverno = '0440923198101075636';