Adalat  Khan

Adalat Khan

  • 655
  • 1.5k
  • 865.8k

LIKE Operator or any Equiavelant

Jun 13 2020 9:33 AM
I have a string field Bands in which i stored some fixed numeric values such as 41, 78, 800, 1800. These values are stored in the Bands field as comma separated. Now to get a single value from this field i used MySql query LIKE operator. Suppose if i want to take the valuee 800 then i am using the following query:
 
Select * from CapacityRequest where Bands LIKE ('%800%')
 
This query returns only 800 that is perfect but when i want to retrieve the value 1800 then it returns both 800 and 1800 for example:
 
Select * from CapacityRequest where Bands LIKE ('%1800%') 
 
The above query returns both 800 and 1800 but i only want 1800 not 800. I also used the following query but it also not working:
 
Select * from CapacityRequest where Bands LIKE ('%18%')
 
The above query also returns both 800 and 1800. How to fix this issue?.
 
I am using this query in C# 
 
 
Thanks in ADVANCE. 
 

Answers (4)