This code is work normally
SELECT 2 IN('1','2','3')
and the result is 1
that means the condition is true but something I don't understand.
I have a associated_roles
table with data like this.
-------------------
|role_col |
-------------------
|1,2,3,4,5 |
-------------------
|1,2 |
-------------------
|1,2,3,4,5,6,9,46 |
-------------------
|1,2,3,5,4,46,333 |
-------------------
The code SELECT replace(role_col,',', '\',\'') from associated_roles
will return
--------------------------------
|role_col |
--------------------------------
|1','2','3','4','5 |
--------------------------------
|1','2 |
--------------------------------
|1','2','3','4','5','6','9','46 |
--------------------------------
|1','2','3','5','4','46','333 |
--------------------------------
Finally I want to get row contain 2
and with IN
and I have no idea why the below code doesn't work properly.
SELECT * from associated_roles where 2 IN(replace(role_col,',', '\',\''))
It's return nothing like this
--------------------------------
|role_col |
--------------------------------
| |
--------------------------------