SQL to check list of value against a table column -
i have table items in column logically grouped. need check list of item exists on table or not. need check exact amount of list.
this table structure , if search against list ("rick" , "max), should have group id 2. but, if search "rick" shouldn't result back.
you can use subquery fetch groups , names, using group by
on groupid
, group names comma separated(ordered) , check input against it.
for example, in mysql.
select * (select groupid, group_concat(name order name) "concnames" my_table group groupid) subquerytable subquerytable.concnames= 'max,rick';
will give you:
------------------ groupid concnames 2 max,rick
then check parameter against concnames
column(your input names should ordered well)
Comments
Post a Comment