开发者

mysql select data from multiple rows

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 tho开发者_如何学运维ught 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?


SELECT * FROM TABLE WHERE keyword = 'guy' AND name in (SELECT name FROM TABLE WHERE keyword = 'developer')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜