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

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -