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

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -