![](/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.