Error in update sql: Subquery returned more than 1 value. This is not permitted when the subquery Follows

Asked

Viewed 251 times

1

I am performing a query to change the net cost of a product according to a brand, however, I get the following error message:

Subquery returned more than 1 value. This is not permitted when the subquery Follows =, != , <, <= , >, >= or when the subquery is used as an Expression. The statement has been terminated.

I tried to:

UPDATE cd_pro
SET CustoLiquido = ((10 * p.CustoLiquido) / 100) + p.CustoLiquido
FROM cd_pro p
  INNER JOIN cd_marcas m
  ON (p.id_marca = m.id_marca)
  WHERE m.id_marca = 1
  • The query SELECT p.CustoLiquido FROM cd_pro p INNER JOIN cd_marcas ON (p.id_marca = m.id_marca) WHERE m.id_marca = 1 is returning more than one value, so there is no way to do the UPDATE using the operation ((10 * p.CustoLiquido) / 100) + p.CustoLiquido. Refactor your query to return only 1 value.

1 answer

0


Does right:

UPDATE cd_pro
SET CustoLiquido = ((10 * CustoLiquido) / 100) + CustoLiquido
WHERE id_marca = 1

As you want to do for the brand and you have the id_tag in the cd_pro table, you will not need to do the Join.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.