I am using PHP
I have an SQL Table that looks like so:
I am trying to retrieve all rows which contain "9" in the "FAMILY" Column How would I do so? Note: The numbers are separated by hyphens "-"
I am using PHP
I have an SQL Table that looks like so:
I am trying to retrieve all rows which contain "9" in the "FAMILY" Column How would I do so? Note: The numbers are separated by hyphens "-"
You need to adopt REGEX
for that I guess.
SELECT * FROM table_name WHERE family REGEXP '[[:<:]]9[[:>:]]';
Note: May be it's high time you normalized your data. Otherwise you might find it troublesome even for doing the simplest manipulation on that column.
Have a look at this:
Is storing a delimited list in a database column really that bad?
Please try this query:
select * from table_name where concat('-',FAMILY,'-') like '%-9-%';