sql - 在oracle中将字符串转换为字符
问题描述
嗨,我有以下数据'1,2,3'
,我需要将其转换为'1','2','3'
我将在此使用的数据
Select * from dual where to_chat(month) in ('1','2','3')
由于quater,我不能像那样直接使用查询
Quater no. Month
1 1,2,3
2 4,5,6
...
所以我必须像这样使用 case 但 case 语句以这样的格式返回'1','2','3'
Select * from dual
where to_chat(month) in (
select
case quarter
when 1 then '1','2','3'
when 2 then '4','5','6'
end
from dual )
输入
'1,2,3'
预期产出
'1','2','3'
解决方案
您可以使用regexp_like()
:
where regexp_like(<whatever>, replace('1,2,3', ',', '|'))
在字符串中加上单引号仍然不能让你做你想做的事情like
。它仍然是一个字符串,但其中包含单引号和逗号。
推荐阅读
- jquery - Importing pages using my own code based on jQuery inspired from Angular
- java - Toggle between two languages Struts2 if else
- django - Docker-compose django nginx doesnt find static files
- c# - C# 中的 DeviceIoControl 导致 998 错误:对内存位置的访问无效
- c - 将值传递给修改后的系统调用函数已更改
- amazon-web-services - AWS lambda 使用事件构建 FilterExpression
- android - 如何在 Android/NDK 上将命令行参数从 gradlew.bat 传递到 Clang
- angular - 无法在 Firebase 和 Angular 中读取 null 的属性“uid”
- python - 创建一个读取文件,存储在数组中,然后打印单词出现在数组中的次数的函数
- javascript - 遇到未捕获的类型错误:无法读取未定义的属性