mysql 查询
有这样一个表
user_id(用户id)ques_id(问题id)their_answer(他们的回答)my_answer(我的回答)
要实现的是 用户的id和所有的id进行比较 查找回答的相同的题,并且查找出相同的题的我的回答和他们的回答,
求高手帮忙写出一个快速查询的sql语句,
------解决方案--------------------
这个意思?
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<br><font color="#e78608">------解决方案--------------------</font><br>自连接<br>select a.* from question a, question b where a.ques_id = b.ques_id and b.user_id=用户1的id<br><br>select a.* from question a, question b where a.ques_id = b.ques_id and b.user_id in (,用户1的id,用户2的id)<br><br><br><font color="#e78608">------解决方案--------------------</font><br>带条件怎么会显示所有的id?<br><br>另外自连接要避免自己跟自己连接<br>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'<div class="clear"> </div>