[英]Comparing a Particular String with another string (multiple values) via Oracle SQL
SQL to Compare one string among multiple values in another string . SQL在另一个字符串的多个值中比较一个字符串。
Example : I have 2 string as following. 示例:我有以下2个字符串。 In
first_string="B"
and in second_string="A,B,C,D,E".
在
first_string="B"
和second_string="A,B,C,D,E".
How do i compare first_string against individual value of second_string? 如何将first_string与second_string的单个值进行比较?
IF the value of the First String is among the values of Second string then i need to proceed with the further actions. 如果“第一字符串”的值在“第二字符串”的值之中,那么我需要继续执行进一步的操作。
If you need to do this using strings, you can use like
: 如果您需要使用字符串来执行此操作,则可以使用
like
:
where ',' || second_string || ',' like '%,' || first_string || ',%'
However, I would suggest that you investigate alternatives to storing such values in strings. 但是,我建议您研究将此类值存储在字符串中的替代方法。 Tables (including nested tables) are a better choice.
表(包括嵌套表)是更好的选择。 You can also use JSON and similar formats.
您还可以使用JSON和类似格式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.