mysql - sql query for product taging to get product having 3 specific tag -


i have database design having 3 table below:

products pid pname pprice  tags  tag_id tag_name  products_tag ==> unique(pid,tag_id) pid tag_id 65   1 65   3 66   2 88   2 88   4 88   3 

i have requirement pid have tagid = 2 , 3 , 4. result in case 88(pid). sql query problem statement?

select pid products_tag  tagid in (2,3,4) group pid having count(tagid) = 3 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -