Hi there.
Within my stored procedure I have a piece of SQL that is supposed to remove from a temporary table, any values that are not set to '1' for a particular field, but this does not work as required.
The SQL in question looks like this:
Can you see what I have done wrong here please, as the test for tab3.THIS_VALUE = 1 is returbning results for THIS_VALUE = 0 also.
Thank you.
Within my stored procedure I have a piece of SQL that is supposed to remove from a temporary table, any values that are not set to '1' for a particular field, but this does not work as required.
The SQL in question looks like this:
Code:
DELETE FROM table1 WHERE value_1 NOT IN ( SELECT tab1.value_1 FROM table1 tab1 JOIN table2 tab2 ON tab1.value_1 = tab2.value_1 AND tab1.line_no = tab2.line_no AND tab1.client = tab2.client JOIN table3 tab3 ON tab3.client = tab2.client AND tab3.THIS_VALUE = 1 AND tab3.value_2 = tab2.value_2 JOIN table4 tab4 ON tab3.client = tab4.client AND tab3.value_3 = tab4.tab4_value JOIN table5 tab5 ON tab5.client = tab4.client AND tab5.art_id = tab4.art_id AND tab5.Sub_id = @SubID AND tab5.Seq_no = @SeqNo AND tab1.client = @Client )
Thank you.
Comment