更新时间:2023-02-05 10:04:08
尝试像下面这样使用 group_concat()
你可以得到 ,
分隔的列表,然后在它们之间加入桌子.但是存储逗号分隔值从来都不是一个好主意.
Try like below by using group_concat()
you can get the ,
separated list and then join between the tables. But storing comma separated values is never a good idea.
update table2 t2
join
(
select ItemID,group_concat(CategoryID) as newcat
from table1 group by ItemID
) tab on t2.ItemID = tab.ItemID
set t2.CatIDs = tab.newcat