下面是3个查询,我希望在mysql中以单个查询的形式运行,我将把这个结果传递给宾得查询组件来绘制一些图表。
SET @input = select "22:4,33:4" from dual;
SET @count := 0;
select SUBSTRING_INDEX(@input, ' ', (@count) * 2), ' ', -1) as xyz, som_cnt as count from abc; 样本字符串的长度未知(22:4,33:4,96:6.)
expected output
xyz count
----------------
22 4
33 4
96 6参考- Mysql Query to Separate space delimited String Convert into 2 columns
我希望mysql链接中有相同的功能,如下所示,我尝试了这个解决方案,但我不确定set_config是否在mysql中工作。SET and SELECT within a single query?
的查询组件中运行存储过程的任何方法。
发布于 2018-10-22 10:08:53
您可以将用户定义的会话变量的初始化移到派生表中,并将Cross Join与其他表一起移动:
SELECT SUBSTRING_INDEX(@input, ' ', (@count) * 2), ' ', -1) AS xyz,
som_cnt AS `count`
FROM abc
CROSS JOIN (SELECT @count := 0,
@input := '22:4,33:4'
) AS user_init_vars https://stackoverflow.com/questions/52924507
复制相似问题