Re: delete based on multipart key
Posted in 1997
In article <33421BB9.2197@gte.net>, Douglas Wilson <dgwilson@gte.net>
writes
>Rudy Fernandes wrote:
>>
>> In article <pz67yez52w.fsf@eeyore.ibcinc.com>,
> I can't figure out an efficient way
>> >to delete all the rows whose keys appear in a second table.
>
>Which reminds me, I've mentioned this before and I'll mention it
>again, there ought to be syntax for this multi-part sort of thing like
>so:
>
>delete from first_table
>where a,b in (select a,b from second_table)>
There is :-
delete from first_table
where 1 in
(select 1 from first_table,second_table
where first_table.a = second_table.a and
first_table.b = second_table.b)
No - I don't fully undetstand it either although I can see how
it could work (subselect 'marks' the rows and delete deletes rows
in the 'marked' set) and it does!!!
Somehow though I still don't feel I totally understand WHY it works...
>Enough griping, back to work,
>Douglas Wilson
>
--
David Williams