![](/img/trans.png)
[英]SQL ERROR: This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression
[英]Error in SQL - This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression
我正在尝试根据两个条件更新字段
UPDATE TABLE1 SET FIELD1 = (SELECT SUBSTRING(LEFT(FIELD2,3),2,2) FROM TABLE1) WHERE FIELD2 LIKE '0%' AND FIELD3 IN ('OK','YES')
UPDATE TABLE1 SET FIELD1 = (SELECT SUBSTRING(LEFT(FIELD2,3),1,2) FROM TABLE1) WHERE FIELD2 NOT LIKE '0%' AND FIELD3 IN ('OK','YES')
Field1的数字以0和1开头。如果以0开头,则更新第一个查询。 如果为1,则第二个查询
您不需要子查询。 所有你需要的是:
UPDATE TABLE1
SET FIELD1 = SUBSTRING(LEFT(FIELD2,3),2,2)
WHERE FIELD2 LIKE '0%'
AND FIELD3 IN ('OK','YES')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.