tags:

views:

32

answers:

2

table1 has 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

+1  A: 

You can use the multitable delete syntax:

DELETE table2
FROM table1
JOIN table2
ON table1.city = table2.city
WHERE table1.country = 'RUSSIA'
Mark Byers
you and ddc have tables in opposite places, are u sure this is right?
I__
I've fixed my mistake in the first line. Regarding the rest, it doesn't matter whether you write `table1 JOIN table2` or `table2 JOIN table1`. These give the same result.
Mark Byers
+1  A: 
DELETE table2
FROM table2 INNER JOIN table1
   ON table2.CITY = table1.CITY
WHERE table1.COUNTRY = 'Russia'
ddc0660
you and mark have table's in opposite places
I__
@Mark Byers has updated his answer to something closer to mine. You want to delete from table2 in your question.
ddc0660