我有一个表 'my_table' 有两列(c1,c2)以完全相同的格式保存数据 '1,2,3,4;5,6,7,8' 我使用 regexp_split_to_table 将它们分成行,我'正在尝试选择非空行。
SELECT * from
(SELECT '1' as param1 ,'2' as param2, param3 FROM
((select regexp_split_to_table(my_table.c1, ';') as param3
FROM my_table)
UNION
(select regexp_split_to_table(my_table.c2, ';') as param3
FROM my_table)) AS a) as b
where param3 is not null
运行此查询会出现以下错误:
set-valued function called in context that cannot accept a set
如果我删除并集并仅从其中一列中选择,或按其他字段之一(param1/param2)过滤,则查询有效。我认为这可能是数据的问题,所以我尝试从同一列中选择两次:
SELECT * from
(SELECT '1' as param1 ,'2' as param2, param3 FROM
((select regexp_split_to_table(my_table.c1, ';') as param3
FROM my_table)
UNION
(select regexp_split_to_table(my_table.c1, ';') as param3
FROM my_table)) AS a) as b
where param3 is not null
但我仍然得到同样的错误。有人知道如何解决这个问题吗?谢谢!