MySQL many-to-many SELECT query -


i have product table, tags table , table links them together, producttags.

product

id 

producttags

productid tagid 

tags

id 

i want query producttags table productids have both tagid 1 , 2. how this?

select * producttags tagid = 1     , tagid = 2 

this won't work... can't quite head round how it!

any appreciated!

this "set-within-sets" query , solve these using group by , having. here 1 method:

select productid producttags tagid in (1, 2) group productid having count(distinct tagid) = 2; 

Comments

Popular posts from this blog

c# - SharpSsh Command Execution -

How to run C# code using mono without Xamarin in Android? -

python - Specify path of savefig with pylab or matplotlib -