Hi, An alternative for any MySQL version (from 3.23.??) would be:
SELECT r1.question_id,count(r1.member_id) FROM Records r1 LEFT JOIN Records r2 ON r1.question_id=r2.question_id AND r2.member_id=<member_id> WHERE r2.question_id IS NULL; <member_id> must be the member name. mpneves On Thursday 19 January 2006 11:18, Gleb Paharenko wrote: > 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 -- AvidMind, Consultadoria Informática, Unipessoal, Lda. Especialistas em OpenSource http://www.avidmind.net OBC2BIP -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]