SQL use SELECT to search for records from a field containing a list of number separated by commas
Posted on 2015-02-20
We have a database that has a field in who contents are lots of strings of numbers separated by commas.
We want to do a select to extract records where this field contains one specific number.
Example of this field could be "15,21,32,45,65,68"
And we want to select it using something like this:
- SELECT ID FROM myTable WHERE myField CONTAINS '21';
So it selects the record if the number exists anywhere in the field, whether it be on it's own or within a list of numbers.