开发者

delete records from a table based on data from a different table

开发者 https://www.devze.com 2022-12-31 19:55 出处:网络
table1 h开发者_如何学JAVAas column CITY and COUNTRY. table2 has column CITY. how do i delete from table2 all records that have CITY in common with table1 but also the COUNTRY=\'Russia\' ??

table1 h开发者_如何学JAVAas column CITY and COUNTRY. table2 has column CITY.

how do i delete from table2 all records that have CITY in common with table1 but also the COUNTRY='Russia' ??

please keep in mind that both tables have about 1 million rows of data


DELETE table2
FROM table2 INNER JOIN table1
   ON table2.CITY = table1.CITY
WHERE table1.COUNTRY = 'Russia'


You can use the multitable delete syntax:

DELETE table2
FROM table1
JOIN table2
ON table1.city = table2.city
WHERE table1.country = 'RUSSIA'
0

精彩评论

暂无评论...
验证码 换一张
取 消