I'm doing a survey module and want to run a single query that gives me the total number of votes in a survey (easy with COUNT and GROUP BY), PLUS whether the logged in user voted in each one or not.
One table is Questions, the second is Votes. Here's what I have - it gives the vote count for each question, but not whether the current user (lcUserCode) voted in each one:
SELECT Questions.*, UserCode, COUNT(UserCode) AS VoteCount ;
FROM Questions ;
LEFT JOIN Votes ;
WHERE Questions.SurveyPK=Votes.SurveyPK ;
ORDER BY CloseDate DESC ;
GROUP BY SurveyPK ;
INTO CURSOR TQuery
SurveyPK is the PK in the Questions table. Of course, I'm interested in listing all questions.
Any ideas?
Kogo Michael Hogan
"Pinky, are you pondering what I'm pondering?"
I think so Brain, but "Snowball for Windows"?
Ideate Web Site