I have a TEXT column in my Table T and contains some values separated by Commas.
Columns BNFT has text values such as
I want to return result in my query only if B3 is present.
It should not consider B30-B39 or B[1-9]3 (i.e. B13, B23 .... B93).
Where BNFT LIKE '%B3,%' or BNFT LIKE '%B3'
Procedures will not work. Query must start with Select as 1st statement.
The first advice is to fix your data structure. Storing lists of ids in strings is a bad idea:
That said, sometimes we are stuck with other people's bad design decisions.
In SQL Server, you would do:
where ',' + BNFT + ',' LIKE '%,33,%'
This question was originally tagged MySQL, which offers
find_in_set() for this purpose:
Where find_in_set(33, BNFT) > 0