Reputation: 57
hello I would like to set a table column I tried with the update query but I have syntax error
$cmts="UPDATE stat_alert INNER JOIN cell_cmt ON stat_alert.cell = cell_cmt.cell SET stat_alert.`cmts` = cell_cmt.`Cmts`";
$cmt= mysql_query($cmts)OR DIE("Erreur sur la requete");
I have erreur sur la requete who can help me
Upvotes: 0
Views: 104
Reputation: 35963
Try this code: you have en error of syntax because from gone before the set. Set have to be after the inner join
UPDATE stat_alert a
INNER JOIN cell_cmt b ON a.cell = b.cell
SET a.`cmts` = b.`Cmts`
Upvotes: 2
Reputation: 263693
You are using version of UPDATE with JOIN
in MSSQL, In MYSQL
, it should be like this, (FROM keyword shouldn't be specified)
UPDATE stat_alert a
INNER JOIN cell_cmt b
ON a.cell = b.cell
SET a.`cmts` = b.`Cmts`
Upvotes: 1
Reputation: 79909
Here is the right syntax for UPDATE
with JOIN
:
UPDATE stat_alert
INNER JOIN cell_cmt ON stat_alert.cell = cell_cmt.cell
SET
stat_alert.`cmts` = cell_cmt.`Cmts`
The mysql UPDATE
dictates that the table references stat_alert
INNER JOIN cell_cmt ON stat_alert.cell = cell_cmt.cell
comes after the UPDATE
clause directly. Thats what you was missing.
Upvotes: 1