Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15772

Need help with this complicated query

$
0
0
Hello vbforums
I have 3 tables as shown below
I want to delete all records that are in both tbl1 and tbl3 but do not exist in tbl2

Name:  query3.jpg
Views: 40
Size:  43.1 KB

this is what I'm doing but no success.

Code:

StrSql = "Select * From Tbl1 inner join Tbl2 on  Tbl1.Id = Tbl2.PID " & _
" inner join Tbl3 on Tbl1.ID = Tbl3.SID" & _
"  where pass =  'Non' and PID <> SID "

 Set Rs = Cnn.OpenRecordset(StrSql)

 If Not Rs.EOF Then
 Do While Not Rs.EOF
    Rs.Delete
 Rs.MoveNext
        Loop
End If
End If

In this scenarion I expect this query to delete Record 4 in Tbl1 and Tbl3.
thank you
Attached Images
 

Viewing all articles
Browse latest Browse all 15772


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>