2 Replies - 2740 Views - Last Post: 30 January 2013 - 11:22 PM

#1 snig08  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 18
  • Joined: 22-January 13

Displaying all information on left and non-matches as NULL

Posted 29 January 2013 - 01:38 PM

My database has a challenges table where there are these columns: Challenge_Name, Challenge_Description. I have a 2nd table called completed_challenges_junction and it has these columns: Member_Name, Challenge_Name.
I need a way to display all of the challenge names from the challenges table along with the member names within the completed_challenges_junction. Where there is no match I would like it to display NULL.
I think I'm pretty close to having my SQL code working, here is what I have now.
SELECT challenges.Challenge_Name, challenges.Challenge_Description, completed_challenges_junction.Member_Names FROM challenges LEFT JOIN completed_challenges_junction ON challenges.Challenge_Name=completed_challenges_junction.Challenge_Name
WHERE Member_Names='membername' OR Member_Names=null

Thanks for any replies.

Is This A Good Question/Topic? 0
  • +

Replies To: Displaying all information on left and non-matches as NULL

#2 Dormilich  Icon User is online

  • 痛覚残留
  • member icon

Reputation: 3549
  • View blog
  • Posts: 10,318
  • Joined: 08-June 10

Re: Displaying all information on left and non-matches as NULL

Posted 30 January 2013 - 09:52 AM

in your WHERE clause, you’re missing the table prefix.
Was This Post Helpful? 0
  • +
  • -

#3 e_i_pi  Icon User is offline

  • = -1
  • member icon

Reputation: 795
  • View blog
  • Posts: 1,681
  • Joined: 30-January 09

Re: Displaying all information on left and non-matches as NULL

Posted 30 January 2013 - 11:22 PM

NULL doesn't equate, you have to use IS NULL instead of = NULL
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1