1.在做更新操作时,要小心不能随便更新,在这种情况下,避免手滑,应该提前对每句更新语句进行注释
--UPDATE T_CMP_LAWSUIT SET F_CASE_TYPE = 'Ajlx07' WHERE F_CASE_TYPE='协助执行通知书';
--UPDATE T_CMP_LAWSUIT SET F_CASE_TYPE = '' WHERE F_ID =(SELECT F_ID FROM T_CMP_LAWSUIT WHERE F_CASE_TYPE NOT LIKE 'Ajlx%');
--SELECT * FROM T_CMP_LAWSUIT WHERE F_CASE_TYPE NOT LIKE 'Ajlx%';
2.很多时候我们需要一次性更新或删除许多条语句,需要带入嵌套
--UPDATE T_CMP_LAWSUIT SET F_CASE_TYPE = '' WHERE F_ID =(SELECT F_ID FROM T_CMP_LAWSUIT WHERE F_CASE_TYPE NOT LIKE 'Ajlx%');
首先查找不符合标准的F_CASE_TYPE对应的F_ID,然后将这些id对应的F_CASE_TYPE 设为空
按上面的语句,会提示:“一条查询语句返回多行”
因为WHERE f_id =(……)=等号后面只能跟一条返回结果
所以应该修改为:【UPDATE T_CMP_LAWSUIT SET F_CASE_TYPE = '' WHERE F_ID IN (SELECT F_ID FROM T_CMP_LAWSUIT WHERE F_CASE_TYPE NOT LIKE 'Ajlx%');】 这里的in 是范围性的匹配!非常重要!!