1

我有两张桌子

question
------------------------------
qid  |  qname  |  description
------------------------------
1      ssc?       blabla

2      BIE        blabla

3      msc        blabla

answer
----------------------------
aid  | uid  | qid | answered_on
-------------------------------
1      1      1     ssc means

2      2      1     ssc
-------------------------------

现在我想得到未回答的问题如何编写查询?你能告诉任何人吗?

i get the result like 

qid | qname
-----------
2     BIE
3     msc
4

2 回答 2

1
SELECT qid, qname FROM question 
WHERE qid NOT IN (SELECT DISTINCT qid FROM answer)

虽然不是真正的服务器故障问题。

于 2012-08-16T08:15:28.930 回答
1
select * from  users as ru left join answers as ra on ru.uid=ra.uid 
left join questions as rq on rq.uid=ru.uid 
where   rq.qid not in(select qid from answers) group by rq.qid order by rq.qid desc

如果您有用户表,这可能很有用

于 2012-08-16T08:18:05.650 回答