I try to update some rows of a table to a different table, for now on I just find out how to insert a row from one table to another, like:
INSERT INTO dialecte_org_5.tb_data_iae (
SELECT * FROM dialecte_org_88.tb_data_iae WHERE id_dialecte = 2413
);
What could be the same statement but for an update?
Is there a way to make something like this, if row exists -> “update”, if not “insert”
Thx
For an insert, You usually want to specify the full field list for both the insert statement and the select (http://dev.mysql.com/doc/refman/5.5/en/insert.html):
And an update statement is more like this (http://dev.mysql.com/doc/refman/5.0/en/update.html):
You also can use REPLACE INTO, which does both, but is MySQL specific, not supported by other RDBMS’s (http://dev.mysql.com/doc/refman/5.0/en/replace.html):