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.

enter image description here

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)

sql fiddle


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -