views:

28

answers:

1

I have a table

id, name, keyword
1   bob    guy
2   bob    developer
3   mary   girl
4   joe    guy

Q1 : What would be the sql to get back the row (bob) containing both keywords 'guy' AND 'developer'?

Intuitively, I thought it'd be SELECT * FROM TABLE WHERE keyword = 'guy' AND keyword = 'developer'

Q2: But I suppose the first conditional AND removes the 2nd row (bob, developer) which causes the sql to return no result? Am I correct about this speculation?

+1  A: 
SELECT * FROM TABLE WHERE keyword = 'guy' AND name in (SELECT name FROM TABLE WHERE keyword = 'developer')
Moak