SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Join Help Needed
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

RichardSteele
Posting Yak Master

158 Posts

Posted - 02/18/2013 :  20:16:19  Show Profile  Reply with Quote
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  Show Profile  Reply with Quote
Ok, got it.
SELECT ID, First, Last, jtpVote FROM masterPortfolioTest LEFT JOIN jurorToPortfolio ON mastID=jtpMastID AND jtpJuror=111 WHERE mastYear=2013
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 02/18/2013 :  23:49:04  Show Profile  Reply with Quote
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/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000