MySQL: How to only select rows where 'set' column has all the values / none of the values -
i have set data type column in mysql table called category_list
can contain 1 or more of following values: category 1
, category 2
.
first question:
to return rows both categories have been selected, use:
"where find_in_set('category 1', category_list) > 0 , find_in_set('category 2', category_list) > 0"
this works fine. when have many categories statement becomes large. there easier/better way select rows categories have been selected?
second question:
to return rows none of categories have been selected, use query:
"where find_in_set('xyz', category_list) = 0"
i make sure xyz
not possible value in set.
this works ok, if add value xyz
set @ later time, these queries break.
is there easier/better way select rows set column has no value?
Comments
Post a Comment