mercredi 5 août 2015

SQLite: join 2 tables with update

I am having two tables which i wish to join.
I am not using foreign keys.

table structure table1 id,val1

table structure table2 id,val2

I am using now following command:
update table1 set val1=(SELECT val2 FROM table2 WHERE table1.id LIKE table2.id)

How can i force sqlite not to insert a value in table1 if an id does not exist in table2?

Aucun commentaire:

Enregistrer un commentaire