mysql 查询,该怎么处理

WBOY
Release: 2016-06-13 13:12:31
Original
874 people have browsed it

mysql 查询
有这样一个表
user_id(用户id)ques_id(问题id)their_answer(他们的回答)my_answer(我的回答)
要实现的是 用户的id和所有的id进行比较 查找回答的相同的题,并且查找出相同的题的我的回答和他们的回答,
求高手帮忙写出一个快速查询的sql语句,

------解决方案--------------------
这个意思?

SQL code
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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template