I have three tables Table1, Table2 and Table3 and the following query which deletes rows in Table2
delete from Table2
where EXISTS
(select (1) from Table1
where Table1.col1=Table2.col1
AND Table1.col2=Table2.col2
AND Table1.col3=(select **Table3.col3 from Table3** inner join Table2 on Table3.col1=Table2.col1)
If col3 of Table1 matches with col3 of Table3 and col1,col2 of Table1 matches with col1,col2 of Table2 then I need to delete the row from Table2. However I am unable to use Table3 in this query. Please help
exists
, so that is allowed to have multiple rows. The innermost select onTable3
, however, is used in a comparison using the=
operator. This subquery is not allowed to return more than one row and is causing the error. Since the query in your question isn't syntactically correct, it would help if you posted the actual query, the table structure and some actual example data. – GolezTrol