views:

48

answers:

1

Say I have an entity A in one table and an arbitrary number of other entities B related to it in other table.

I have a situation where I need to replace all those B entities with a list of new B entities in a way that there should be no duplicates.

Simple way would be to issue a DELETE query first to remove all the old ones and then an INSERT query for new ones but I wonder if there's a way to do it in one query?

A: 

You could use REPLACE to replace rows in a table.

Sjoerd
it will only work in case of duplicates, I also need to delete all the old non-duplicates. REPLACE wont affect them.
Anton