0

I am using PHP
I have an SQL Table that looks like so: SQL Table:

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 "-"

Ideen
  • 47
  • 7

2 Answers2

2

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?

Community
  • 1
  • 1
1000111
  • 12,709
  • 2
  • 24
  • 33
0

Please try this query:

select * from table_name where concat('-',FAMILY,'-') like '%-9-%';
Dipanwita Kundu
  • 1,639
  • 1
  • 8
  • 14