vendredi 31 juillet 2015

SQL - update main table using temp table

I have a question about SQL, especially SQLite3. I have two tables, let's name them main_table and temp_table. These tables are based on the same relational schema so they have the same columns but different rows (values).

Now what I want to do:

For each row of the main_table I want to replace it if there is a row in a temp_table with the same ID. Otherwise I want to keep the old row in the table.

I was thinking about using some joins but it does not provides the thing I want.

Would you give me an advice?

EDIT: ADITIONAL INFO:

I would like to avoid writing all columns because those tables conains tens of attributes.

Aucun commentaire:

Enregistrer un commentaire