You should use ###[Merge Queries][1] > a Merge query is a combination of an Insert query and an Update query. > If a given condition is met, such as a row with a given primary key > already existing, then an Update query is run. If not, an Insert query > is run. [1]: https://www.drupal.org/node/310085