私は2つのテーブルを持っています。table1がtable2と等しいMODEL
ときに、table2を更新したい。ITEM
ITEM
何か案は?
If I understand correctly, you just want to perform an UPDATE
on table2
based on, presumably, foreign keys?
If that's right, this should work:
UPDATE
table2
JOIN table1
ON table1.ITEM = table2.ITEM
SET
MODEL = 'new value';
The table declaration in an UPDATE
statement is the same as is specified in a SELECT
statement - so you can use any type of JOIN
that fits your table/data.
Docs for UPDATE
, SELECT
.
MySQLでは、次のようにします
UPDATE table1 t1
INNER JOIN table2 t2
ON t1.id = t2.id
SET t1.col1 = t2.col1,
t1.col2 = t2.col2
If you could add an actual query attempt, or something, that might be helpful. Can you try something like the following:
UPDATE table2 JOIN table1 ON table2.ITEM = table1.ITEM SET MODEL = ?