![](/img/trans.png)
[英]MySQL possible to update multiple rows with different where clause, single query
[英]Update query with multiple table in where clause in MySql
我想在表lp_term_relationships
中设置term_taxonomy_id
='4',其中post_title
就像'%Apple%'。 列post_title
在表lp_posts
。 但这给了我语法错误。 有帮助吗??
这是我的查询:
Update `lp_term_relationships`
set `lp_term_relationships`.`term_taxonomy_id` = '4'
FROM `lp_term_relationships`, `lp_posts `
WHERE `lp_posts`.`post_title` Like '%Apple%';
您需要在此处执行适当的加入。 您还没有提到链接它们的外键关系...也将外键关系添加到where子句中。您的最终查询将如下所示:
update table1, table2
set table1.col=1
where table1.id= table2.fkey_id
and table1.column2 like '%APPLE%'
您需要编写正确的列名和链接表的关系。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.