Error: subquery returning more than one result

2

Given sql:

DELETE FROM wgcartarmazens
 WHERE (
   SELECT artigo 
     FROM wgcartarmazens as T 
    INNER JOIN wgcartigos as A ON A.CODIGO=T.ARTIGO
    WHERE T.lote='' AND A.TEMLOTE<>0
 );

The above query returns me the following error

  

subquery returns more than 1 value this is not allowed when the   subquery follows

How can I fix it?

    
asked by anonymous 27.02.2014 / 16:45

1 answer

4

If you want to do a DELETE in all subquery fields, do so:

DELETE FROM wgcartarmazens
 WHERE artigo IN (
   SELECT artigo 
     FROM wgcartarmazens as T 
     JOIN wgcartigos as A ON A.CODIGO = T.ARTIGO
    WHERE T.lote = ''
      AND A.TEMLOTE <> 0
 );
    
28.02.2014 / 13:48