动力节点旗下在线教育品牌  |  咨询热线:400-8080-105 学Java全栈,上蛙课网

用的是SQL数据库,现在有两个系列 id分别 1 3 如何根据series_follow查出来对应的花卉

十年

2020.07.17

现在有两个系列 id分别 1 3 如何根据series_follow查出来对应的花卉

添加回答

回答(1)

十年

把 flower_series和flowers这两个表名改一下就能用了。

 

select a.id,GROUP_CONCAT(follow_name) as flowers 
from (
SELECT a.id,
replace(substring_index(substring_index(replace(replace(a.series_follow,'[',''),']',''),',',b.id+1),',',-1),' ','') as flowerid
FROM flower_series a
JOIN (SELECT (@ROW :=@Row + 1) as id FROM flowers,(SELECT @Row:=-1) s) b 
on b.id<(length(replace(replace(a.series_follow,'[',''),']','')) - length(REPLACE (replace(replace(a.series_follow,'[',''),']',''), ',', '')) + 1)) a 
join flowers b on a.flowerid=b.id
group by a.id;

时间:07-17 17:18 查看回复 (0) 回复 0 0 举报

回复