Hello.
Perhaps this will work (depends on the version of MySQL you're using):
select question_id
, count(*)
from Records
group by question_id
having question_id not in (
select distinct question_id
from Records r
where member_id = @current_member_id);
@current_member_id equals to current_user
G G wrote:
> Hello,
>
> I have a simple Records table with two columns, member_id and question_id.
>
>
>
> The object of the query is to retrieve the question_id, as well as how many
> times it's been answered - as long as the current user hasn't answered it
> (member_id). So, the query shouldn't return any question_id's (and counts)
> if it has been answered by the current user.
>
>
>
> Right now I have this:
>
> SELECT question_id, COUNT(*) as times_answered FROM records GROUP BY
> question_id;
>
>
>
> I've tried throwing in different variants of 'WHERE member_id != X', but all
> that seems to return is the count of questions answered, minus the amount of
> times the particular user has answered them. For example, if user X has
> answered a question that had been answered another 50 times, my query will
> still return that question_id, but with a count of 49.
>
>
>
> Your help is appreciated in advance. Thanks!
>
>
>
>
>
> Kind Regards,
>
> Gerald Glickman
>
>
>
> G2 Innovations.com, Inc.
>
> http://www.g2innovations.com <http://www.g2innovations.com/>
>
>
>
>
--
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.NET http://www.ensita.net/
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Gleb Paharenko
/ /|_/ / // /\ \/ /_/ / /__ [EMAIL PROTECTED]
/_/ /_/\_, /___/\___\_\___/ MySQL AB / Ensita.NET
<___/ www.mysql.com
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]