sql - Check single column for multiple values mysql -


i have table 'optionsproducts' having following structure , values

id      optionid      productid 1       1             1 1       2             1 1       3             1 1       2             2 1       2             3 1       3             3 

now want extract productids against both optionid 2 , optionid 3 assigned. means in case productid 1 , 3 should returned. not sure missing. appreciated.

to productids relate both 2 , 3 optionids, can write similar query:

select productid   ( select productid               , optionid               , dense_rank() over(partition productid                                    order optionid) rn            t1           optionid in (2,3)         ) s s.rn = 2 

result:

productid ---------- 1 3 

sqlfiddle demo


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -