简体   繁体   English

SQL错误-子查询后跟=,!=,<,<=,>,> =或将子查询用作表达式时,不允许这样做

[英]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.

相关问题 SQL错误:当子查询遵循=,!=,&lt;,&lt;=,&gt;,&gt; =或将子查询用作表达式时,不允许这样做 - SQL ERROR: This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression sql server error =当子查询跟随=,!=,&lt;,&lt;=,&gt;,&gt; =或将子查询用作表达式时,不允许这样做 - sql server error = This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression 当子查询遵循=,!=,&lt;,&lt;=,&gt;,&gt; =或用作表达式时,不允许使用 - Not permitted when the subquery follows =, !=, <, <= , >, >= or when used as an expression 当子查询遵循=,!=,&lt;,&lt;=,&gt;,&gt; =或将子查询用作表达式时,不允许这样做 - This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression 如何解决错误:“子查询返回了多个值”。 当子查询遵循=,!=,&lt;,&lt;=,&gt;,&gt; =或用作表达式时,不允许使用 - How to fix error: “Subquery returned more than 1 value”. Not permitted when subquery follows =, !=, <, <= , >, >= or used as an expression SQL Server子查询返回了多个值。 当子查询跟随(字符)或子查询用作表达式时,不允许这样做 - SQL Server Subquery returned more than 1 value. This is not permitted when the subquery follows (chars) or when the subquery is used as an expression 子查询返回超过 1 个值。 当子查询跟随......或当子查询用作表达式时,这是不允许的 - Subquery returned more than 1 value. This is not permitted when the subquery follows … or when the subquery is used as an expression 子查询返回的值超过1。 当子查询遵循&gt; =或将子查询用作表达式时,不允许这样做 - Subquery returned more than 1 value. This is not permitted when the subquery follows>= or when the subquery is used as an expression 当子查询遵循=,!=,&lt;,&lt;=,&gt;,&gt; =时,不允许这样做 - This is not permitted when the subquery follows =, !=, <, <= , >, >= 当子查询遵循=,!=,&lt;,&lt;=,&gt;,&gt; =或将子查询用作表达式时,不允许这样做。 返回了多个值。 - This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. More than 1 value was returned.
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM