我对 SQL Server 还很陌生,仍在学习一些交易技巧,而另一个教我的人一周没有工作,通常我会先运行他的语句,然后运行它。
我要做的是删除此 select 语句中返回的所有内容:
SELECT * from LOCATIONS a Join CONTACTS b on a.location_ID = b.Location_ID
join CONTACTS_SOURCES c on b.contact_ID = c.Contact_ID where c.Source_ID = 10014918
我需要删除此语句从 CONTACTS 表和 LOCATIONS 表返回的内容。这样做时,哪条路线是最好的路线?
路线A:
delete from LOCATIONS a
Join CONTACTS b
on a.location_ID = b.Location_ID
join CONTACTS_SOURCES c
on b.contact_ID = c.Contact_ID where c.Source_ID = 10014918
或路线 B。
DELETE from LOCATIONS where (SELECT * from LOCATIONS a
Join CONTACTS b
on a.location_ID = b.Location_ID
join CONTACTS_SOURCES c
on b.contact_ID = c.Contact_ID where c.Source_ID = 10014918)
DELETE FROM CONTACTS where (SELECT * from LOCATIONS a
Join CONTACTS b
on a.location_ID = b.Location_ID
join CONTACTS_SOURCES c
on b.contact_ID = c.Contact_ID where c.Source_ID = 10014918)
我感觉 Route A. 不会从 LOCATIONS 和 CONTACTS 表中删除。