[英]Update mysql table based on data from another table
我想用另一个表中的数据更新 mySql 中的一个表。
我有两个表“模板”和“通知”。 模板表通过名为“event_id”的列链接到通知表。
templates notifications
id id
event_id global_id
我想根据值 templates.event_id = notification.global_id 使用通知表中的 id 更新模板表 event_id。
我尝试这样的事情..但它不能像我想要的那样工作。
'UPDATE templates
INNER JOIN notifications
ON templates.event_id = notifications.id
SET templates.event_id = notifications.id
WHERE templates.site_id = ? AND notifications.global_id = ?';
也许是这样的:
UPDATE templates
JOIN notifications
ON templates.site_id = ? AND notifications.global_id = ?
SET templates.event_id = notifications.id
;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.