How to combine 'LIKE' and 'AND' operator in query in ORACLE.
Suppose for example that I have the TEST table as shown below:
------------------------------------
col1 | Col2
------------------------------------
A | RED
B | RED,BLUE
C | BLUE,GREEN
D | YELLOW,RED
------------------------------------
Now, if i am writing query as shown below that will return all records where either of them exists ie 'A,B,C,D'.
[Since here 'OR' operator is involved in REGEXP_LIKE]
SELECT * FROM TEST WHERE REGEXP_LIKE(COL2,'ED|UE');
But I want AND
operator to be used with LIKE
. So it should return only C
where both of them should exist.
How to write query for the same ?
You could try:
SELECT * FROM test
WHERE Col2 LIKE '%ED%'
AND Col2 LIKE '%UE%'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.