Thank you.
Here is another one
delete from M2m where Pk1 # All (select Pk from Dok1) ;
and Pk2 # All (Select PK from Dok1)
All the best.
>I like second better because it self-describing. However the first one most likely will be faster in VFP.
>The subqueries in second query are called correlated queries because they are referencing fields from the main sql statement. IOW, M2m in subqueries is the table to which DELETE is applied.
>
>>I have a cross-link table for many-to-many named M2m.
>>After testing I'd like to remove trash records from it. M2m links records in Dok1 table. Here are two deletes:
>>
>>1.
>>delete M2m from M2m Left Join Dok1 T1 on T1.Pk=M2m.Pk1 ;
>> Left Join Dok1 T2 on T2.Pk=M2m.Pk2 ;
>> Where isnull(T1.Pk) and isnull(T2.Pk)
>>
>>2.
>>delete from M2m where not exists (select Pk from ;
>> Dok1 where Pk=M2m.Pk1) and not exists (Select PK ;
>> from Dok1 where Pk=M2m.Pk2)
>>
>>Which one of them is better or maybe you suggest your version.
>>I also have a question about statement Nr2.
>>How do subqueries behaive in such cercumstances? Do they behaive like completely seperate Selects? In my example would the subquery: (Select Pk from Dok1 where Pk=M2m.Pk1) consider M2m for the Delete and M2m for itself as two different tables? So that for every subquery Recno('M2m') will show the same number.
>>
>>Kamil
A moment of silence is our cosmic reset button.