Search code examples
sqlvb.netjet

How set LIKE criteria for specific chars in Jet, Access


I have field UPon in my table with following values :

1,15,28
2,17,28
121,217,33
181,17
66,45,1171
988,38
17

For example, I need result for record which contain only 17

Now, if I use UPon LIKE '%17%' then I'll get records bellow:

2,17,28
121,217,33
181,17
66,45,1171
17

But, I need sql query return only records 2,17,28, 181,17and 17

I can't use , in criteria because this char can be anywhere or not be at all.


Solution

  • (making this an answer as it's what you decided to go with and will make it easier for any future readers to find, rather than in the comments)

    you could just expand your query to or the 4 cases - i.e. = '17' or like '%,17,%' or like '17,%' or like '%,17'