I want to achieve this.
I have a target table and a stage table
I want to delete data from target table that is present in the stage table .i.e. all the matching records in stage and target table based on a key should be deleted from the Target table
How are these two logic different
Code: Select all
Delete from target_table
where exists
(select null from stage_table
where stage_table.column_key=target_table.column_key);
Code: Select all
I tried figuring it out what is number of matching records between the two tables
select count(column) from target_table inner join stage_table
on stage_table.column_key=target_table.column_key;
Strangely the first query gives me a different result then the second query.
What might be the reason and what is best solution in my case.