mysql - Select ID That has multiple attributes and values -
i have table1 :
+----+-------+ | id | name | +----+-------+ | 1 | name1 | | 2 | name2 | | 3 | name3 | | 4 | name4 | +----+-------+
i have table2 :
+------+---------+----------+
| id | attribut| value |
+------+---------+----------+
| 1 | 1 | 1 |
| 1 | 3 | 3 |
| 2 | 1 | 1 |
| 2 | 3 | 4 |
+------+---------+--------- +
i want select distinct id(s) , name(s) in table1 have ( attribut 1 , value 1) , (attribut 3 , value 3) in table 2
the result 1/name1 in case
thanks !!
select * table1 id in(select id table2 (attribut, value) in ( (1,1), (3,3) ) group id having count(*)=2 )
Comments
Post a Comment