php - Query with multiple values in a column -
i have table like:
id name children 1 roberto michael,dia 2 maria john,alex 3 mary alexandre,diana
my problem is; want find has child named alex.
i can't use "where children = 'alex'"
in sql because have more 1 names in same cells.
so use "where children '%alex%'"
- looks smart in same time start alex :( alexandre or want dia result dia , diana :(
how can single alex in data type?
i hope can explain problem terrible english :d
the best solution normalize schema. should have separate table 1 row each child, instead of comma-delimited list. can join table find parent specific child. see @themite's answer example of this.
but if can't reason, can use find_in_set
:
where find_in_set('alex', children)
Comments
Post a Comment