日期:2014-05-17 浏览次数:20486 次
select a.user_id,a.my_answer from question a inner join (select ques_id from question where user_id=1 ) t on a.ques_id=t.ques_id
------解决方案--------------------
自连接
select a.* from question a, question b where a.ques_id = b.ques_id and b.user_id=用户1的id
select a.* from question a, question b where a.ques_id = b.ques_id and b.user_id in (,用户1的id,用户2的id)
------解决方案--------------------
带条件怎么会显示所有的id?
另外自连接要避免自己跟自己连接
select a.* from question a, question b where a.ques_id = b.ques_id and a.user_id <> b.user_id and b.user_id = '用户1的id'