简体   繁体   中英

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. I have a table with one column that i generate some values ex 100001 , 100002 etc.

The barcode column for the target table is not null is an empty string. 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
Subquery returned more than 1 value. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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