[英]Convert T-SQL stored procedure query to MySQL
I am working on convert queries from MS SQL Server to MySQL我正在将查询从 MS SQL 服务器转换为 MySQL
My SQL Server Query is as per below.我的 SQL 服务器查询如下所示。
SELECT userId,IndustriesID,value AS ProvIndusID
FROM #Talent_list
CROSS APPLY STRING_SPLIT(IndustriesID,',')
I am stuck here to convert string to row and cross apply.我被困在这里将字符串转换为行并交叉应用。
MySQL doesn't have functions that return tables. MySQL 没有返回表的函数。 You can replace the logic with a recursive CTE:
您可以用递归 CTE 替换逻辑:
with recursive cte as (
select state, cast(null as char(100)) as city, cities, 0 as lev
from talent_list
union all
select state, substring_index(cities, ',', 1),
substr(cities, length(substring_index(cities, ',', 1)) + 2), lev + 1
from cte
where cities <> '' and lev < 5
)
select state, city
from cte
where lev > 0;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.