how to get the un answered questions in quetion table?
سؤال
I have a two tables
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
-------------------------------
Now i want to get the un answered questions how to write the query?can You tell any one.
i get the result like
qid | qname
-----------
2 BIE
3 msc
المحلول
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
this is may be usefull check it if you have a users table
نصائح أخرى
SELECT qid, qname FROM question
WHERE qid NOT IN (SELECT DISTINCT qid FROM answer)
Not really a server fault question though.
لا تنتمي إلى StackOverflow