我不知道怎么称呼它。 我这张桌子就在这里:
正如您可以看到Titon
跟随SLH_444
和Knoedel_475
。
现在,如何为Titon
关注的用户选择所有行?
我希望username
为SLH_444
或Knoedel_475
http://sqlfiddle.com/#!2/4a986/1
这是我到目前为止所做的,但它是错误的,因为子查询返回的行数超过1行
SELECT * FROM ACTIVITIES
WHERE targetname =
(select targetname from ACTIVITIES
where activity='followed' and username='Titon');
答案 0 :(得分:2)
我想你想要:
SELECT * FROM ACTIVITIES
WHERE username in
(select targetname from ACTIVITIES
where activity='followed' and username='Titon');
虽然Titon没有关注SLH_444
,但他已关注SLB_444
。
答案 1 :(得分:1)
SELECT targetname FROM ACTIVITIES WHERE username = 'Titon' AND activity = 'followed';
答案 2 :(得分:0)
select * from tablename where activity='followed' and username='Titon'