输入字符串到表
我正在对 Oracle 10g 的 SQL 进行一些调试。我有一个大输入字符串,用于“IN 子句”,即
select * from table where col in ('str2','str3','str4','str5',...)
我想将 in 子句转换为行或表? 有没有办法做到这一点,即
select 'str2','str3','str4','str5', .. from dual
,但这会输出多列,而我想要多行?
编辑:
这就是我正在尝试做的事情。假设我在 tmp_table1 中有一个 excel 数据(实际上无法创建)并且 tmp_table1 与 IN 子句相同,那么下面的语句将给出丢失的键。
SELECT *
FROM tmp_table1
WHERE unique_id NOT IN (
SELECT unique_id
FROM table1
WHERE unique_id IN
('str1', 'str2', 'str3', 'str4'))
现在@andriy-m 解决方案 有效。但如果它更大怎么办?
I am doing some debugging in SQL for oracle 10g. I have a big input string which is used in "IN Clause" i.e.
select * from table where col in ('str2','str3','str4','str5',...)
i want to convert the in clause to rows or table?
Is there a way to do this i.e.
select 'str2','str3','str4','str5', .. from dual
but this outputs multiple columns and i want multiple rows?
Edit:
Here is what i am trying to do. suppose i have an excel data in tmp_table1 (cant create in reality) and tmp_table1 is same as the IN clause, then the below statement will give the missing keys.
SELECT *
FROM tmp_table1
WHERE unique_id NOT IN (
SELECT unique_id
FROM table1
WHERE unique_id IN
('str1', 'str2', 'str3', 'str4'))
now @andriy-m solution works if the in string is less than 4000. but what if its greater?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能正在寻找
You are probably looking for this solution.
您可以将值合并为多行:
You can UNION the values into multiple rows: