[英]Error in SQL - This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression
I am trying to update a field based on two conditions 我正在尝试根据两个条件更新字段
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 has numbers that begin with 0 and 1. If it begins with 0 then updates the first query. Field1的数字以0和1开头。如果以0开头,则更新第一个查询。 If 1 then second query
如果为1,则第二个查询
You don't need the subqueries. 您不需要子查询。 All you need is:
所有你需要的是:
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.