sql - How do I match against multiple conditions on a table join? -
i have 2 tables:
users attributes id|name id|name|user_id ------- --------------- 1 |foo 1 |bla | 1 2 |bar 1 |blub| 1 1 |bla | 2
how create query gives users both "bla" , "blub" attributes?
in case should return user "foo".
i know data not normalized.
select u.*, a.id, b.id, a.name, b.name users u join attributes on a.user_id = u.user_id , a.name = 'bla' join attributes b on u.user_id = b.user_id , b.name = 'blub'
Comments
Post a Comment