0

I have two databases with the same structure. How can i delete records from db1.table, that exists in db2.table?

db1 table: a - 1, a - 2, b - 1, c - 1

db2 table: a - 1, a - 2, c - 1, c - 2

result: b - 1

Update:

This query doesn't work

DELETE t1 
FROM table t1 
JOIN db2.table t2 
WHERE t1.PrdID = t2.PrdID AND t1.CategoryID=t2.CategoryID

It gives me error

near "t1": syntax error: 

db2 is attached to db1

Andrey Rankov
  • 1,964
  • 2
  • 17
  • 33

1 Answers1

-1

Try this, before delete, test the subquery,

DELETE FROM table1 WHERE (your column) IN (SELECT (your_column) FROM table2)

(Not tested)

Jorge Hess
  • 550
  • 2
  • 9