Reputation: 1539
I have a table like this;
|----------------------|
|field1 | field2 |
|----------------------|
|1,2,3,0 | area 1 |
|5,7,8 | area 2 |
|10,6 | area 3 |
|----------------------|
I have a query like this :
select * from areas where field1 like '%0%'
This query giving me area 1
and area 3
. But I want to get only area 1
because 0 is only in area 1
. Also I tried field1 like '0%'
but it gave me no row.
Upvotes: 0
Views: 117
Reputation: 37243
try this
select * from areas where field1 like '%,0%' or
field1 like '%,0,%' or
field1 like '0,%'
Upvotes: 0
Reputation: 11609
Try This Query
:
select * from areas where field1 like '%,0%'
Thanks OSSCube Solution
EDIT
select * from areas where field1 like '0%' or field1 like '%,0%'
Upvotes: 1
Reputation: 29985
Normalize your table. It's the only good way to solve this problem.
Upvotes: 5