| Author |
Topic  |
|
|
RichardSteele
Posting Yak Master
158 Posts |
Posted - 02/18/2013 : 20:16:19
|
I have two mySQL tables created for a contest. Table 1 has the contestant info, table 2 has the votes. A record is inserted into table 2 whenever there a vote by a judge.
I'd like to show all contestants (all records in table 1) along with their votes, even if no votes have been cast yet.
The following only brings up the contestants that have voted only. Note the jtpJuror is from the JurortoPortfolio as I only want to show votes from that one juror.
SELECT ID, First, Last, jtpVote FROM masterPortfolioTest LEFT JOIN jurorToPortfolio ON mastID=jtpMastID WHERE mastYear=2013 and jtpJuror=111
What would the SQL look like to bring up all contestants regardless if they have received votes or not by the specified juror and show their votes if they have received votes.
Thanks in advance. |
Edited by - RichardSteele on 02/18/2013 20:33:23
|
|
|
RichardSteele
Posting Yak Master
158 Posts |
Posted - 02/18/2013 : 20:53:47
|
Ok, got it. SELECT ID, First, Last, jtpVote FROM masterPortfolioTest LEFT JOIN jurorToPortfolio ON mastID=jtpMastID AND jtpJuror=111 WHERE mastYear=2013 |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47969 Posts |
Posted - 02/18/2013 : 23:49:04
|
One thing to note is that this is a forum dedicated to MS SQL Server so there are not enough people with expertise on MySQL. The solutions given here are guaranteed to work only on sql server. So if you're using MySQL, you may be better off posting questions in some MySQL forums like www.dbforums.com
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
| |
Topic  |
|