| Schweb's Lounge Forum for general conversation, chit chat, or most topics that don't fit in another forum. |
| Post Reply | New Thread | Subscribe |
|
|
Thread Tools |
![]() Member Since: Jun 11, 2003
Location: Mount Vernon, WA
Posts: 4,906
![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: MacBook Pro 2.6 GHz Core 2 Duo 4GB RAM OS 10.5.2
|
Ok guys, i just can't figure this one out. Ill give you the scenario... and hopefully someone can figure this one out for me.. it's got to be simple, but my brain isn't working apparently
![]() We have a contests table, a entries table and a voting table When a person submits a contest, then people can submit entries to that contest, so the index relationship would be contest.id to entry.contest_id and then the contest people can vote on the entry to their contest, so contest.id connects to entry.contest_id and entry.id connects to vote.entry_id Now it's easy to figure out how many people have responded to a contest: select count(*) from entries where contest_id = '1' But now how do I figure how many entries he has that he has not voted on? especially when others can vote on it, so it's not like if I did a left join there would be null values for the vote, there could be multiple matches, but none with that user's id.. I hope that makes sense.. so for example: select * from entries e left join votes v where e.contest_id = '1' if there are no votes then it will return the entries that have not been voted on and the votes values would all be null values. But if there are votes for that entry by other people besides the person that created the contest, then it will return values for the votes, when what I need is just to find out the total number of entries to their contest that they have not voted on yet. Any ideas? I would hate to do multiple queries
---> Join the Mac-Forums Folding team: use 37954 as your team number.View Mac-Forums Folding team statistics (More Info) Don't forget to use the User Reputation System |
| QUOTE Thanks | |
![]() Member Since: Mar 22, 2007
Location: UK
Posts: 1,463
![]() ![]() ![]() ![]() Mac Specs: Lenovo Z560 Hackintosh -:- '06 iMac -:- iPod Touch 2ndGen
|
You need to query the voting table - for each person, get the number of votes grouped by entry_id - you should get 0 or 1 for each of them. of the top of my head:
select count(*) from votes group by entry_id where person=<whatever> That syntax is probably wrong, I usually use Access to build queries like this, but that should do what you're after. [URL="http://beadia.net"]Beadia[/URL - Jewelry Business Management Software] I judge you when you use poor grammar.
Last edited by knightlie; 07-13-2007 at 03:23 AM. Reason: Wrong table |
| QUOTE Thanks | |
![]() Member Since: Jun 11, 2003
Location: Mount Vernon, WA
Posts: 4,906
![]() ![]() ![]() ![]() ![]() ![]() ![]() Mac Specs: MacBook Pro 2.6 GHz Core 2 Duo 4GB RAM OS 10.5.2
|
---> Join the Mac-Forums Folding team: use 37954 as your team number.View Mac-Forums Folding team statistics (More Info) Don't forget to use the User Reputation System |
||||
| QUOTE Thanks | |||||
![]() Member Since: Mar 22, 2007
Location: UK
Posts: 1,463
![]() ![]() ![]() ![]() Mac Specs: Lenovo Z560 Hackintosh -:- '06 iMac -:- iPod Touch 2ndGen
|
Quote:
select contest.*, count(<my query>) from contest I'm sure you can do it, you just need to nest a few queries. You might even need to create a View (or whatever MySQLs equivalent it) and query that as an intermediate step. [URL="http://beadia.net"]Beadia[/URL - Jewelry Business Management Software] I judge you when you use poor grammar.
|
|
| QUOTE Thanks | ||
| Post Reply | New Thread | Subscribe |
| Thread Tools | |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|
|||||||
Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Fresh install of MySQL denies access to root | IceLatte | Web Design and Hosting | 0 | 06-24-2007 05:04 PM |
| MySQL Configuration = :( | jimz | Web Design and Hosting | 2 | 04-13-2006 07:25 AM |
| long shot: php mysql column represent query? | gort | Web Design and Hosting | 1 | 01-22-2006 06:31 PM |
| Installing mySQl on Mac OS X | sealey | Web Design and Hosting | 7 | 06-02-2005 10:45 PM |
| Removing MySQL from Panther 3.6 | vawolf | OS X - Operating System | 0 | 12-07-2004 09:25 PM |
All times are GMT -4. The time now is 11:55 PM.
Powered by vBulletin