MySQL根据部分查询结果更新列
我正在尝试基于MySQL查询更新一个表列。 问题是查询结果分为两列,但我只需要更新category列 未分类 标题匹配 查询MySQL根据部分查询结果更新列,mysql,Mysql,我正在尝试基于MySQL查询更新一个表列。 问题是查询结果分为两列,但我只需要更新category列 未分类 标题匹配 查询 SELECT distinct not_categorized.id, category_lookup FROM not_categorized left JOIN title_match ON not_categorized.category_lookup LIKE CONCAT('%', title_match.title, '%') group by id;
SELECT distinct not_categorized.id, category_lookup
FROM not_categorized
left JOIN title_match ON not_categorized.category_lookup LIKE CONCAT('%', title_match.title, '%')
group by id;
这给了我正确的结果。根据“Chino”一词,分类应为“牛仔裤/裤子”
查询结果
-------------------------
| id | category |
-------------------------
| 1 | Trousers / Jeans |
-------------------------
| 2 | Jackets / Coats |
-------------------------
我现在如何更新“not_characterized”表中的列“category1”
这不起作用:
update not_categorized
set category1 = **QUERY**
查看数据时,可以使用基于标题和类别查找的内部联接
update not_categorized
inner join title_match on not_categorized.category_lookup = title_match.title
set not_categorized.category1 = title_match.category1
很好,我所做的唯一更改是使用CONCAT(“%”,title_match.title,“%”)代替=title_match.title。谢谢你的帮助!
update not_categorized
set category1 = **QUERY**
update not_categorized
inner join title_match on not_categorized.category_lookup = title_match.title
set not_categorized.category1 = title_match.category1