简体   繁体   English

从子查询更新列

[英]Updating column from a subquery

I have a result set from a query that returns the plu code and the barcode columns with some conditions.我有一个查询的结果集,该查询返回 plu 代码和带有某些条件的条形码列。 I have a table with one column that i generate some values ex 100001 , 100002 etc.我有一个包含一列的表,我生成一些值,例如100001100002等。

The barcode column for the target table is not null is an empty string.目标表的条形码列不是 null 是一个空字符串。 The source and the target table they don't have anything common to join them.源表和目标表他们没有任何共同的东西来加入他们。

This is what i get.这就是我得到的。

Msg 512, Level 16, State 1, Line 22消息 512,第 16 层,State 1,第 22 行
Subquery returned more than 1 value.子查询返回超过 1 个值。 This is not permitted when the subquery follows =, ,=, <, <=, >.当子查询跟随 =, ,=, <, <=, > 时,这是不允许的。 >= or when the subquery is used as an expression. >= 或当子查询用作表达式时。

This is my query.这是我的查询。

UPDATE ARTICULOSLIN SET CODBARRAS = (SELECT DISTINCT BRC FROM BRC) FROM ARTICULOSLIN ARL
LEFT JOIN ARTICULOS AR ON (ARL.CODARTICULO = AR.CODARTICULO)
WHERE AR.PORPESO = N'F' AND AR.DESCATALOGADO = N'F' AND LEN(ARL.CODBARRAS) != 13

The error message means that you cannot assign multiple values to a single attribute, I believe your subquery returns all values from table BRC.错误消息意味着您不能为单个属性分配多个值,我相信您的子查询会返回表 BRC 中的所有值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM