'How to select 3 specific pattern in column using SQL? What is wrong with my code?
SELECT * FROM Customers
WHERE CustomerName LIKE ('%aa%','%bb%','%cc%');
Solution 1:[1]
Try splitting your conditions like this
WHERE CustomerName LIKE '%aa%' OR CustomerName LIKE '%bb%' OR CustomerName LIKE '%cc%'
Solution 2:[2]
SELECT * FROM Customers WHERE CustomerName LIKE '%aa%' OR CustomerName LIKE '%bb%' OR CustomerName LIKE '%cc%'
Solution 3:[3]
You can also use the following code
SELECT * FROM Customers
WHERE
instr(CustomerName,'aa')>0 or instr(CustomerName,'bb')>0 or instr(CustomerName,'cc')>0
However this is working in oracle 11G, Please check the compatibility as well
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ikyong |
| Solution 2 | Vivek Kumar Singh |
| Solution 3 | Akanksha |
