SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: WHERE for JOIN?

  1. #1
    SitePoint Guru downtroden's Avatar
    Join Date
    Dec 2004
    Location
    illinois
    Posts
    975
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    WHERE for JOIN?

    Code SQL:
    SELECT projects.*, project_members.user_id AS leader
    FROM projects
    LEFT JOIN project_members ON project_members.project_id = projects.id 
    WHERE projects.id = '3' 
    AND project_members.leader = 1;

    I need this to join only one row from the project_members table, all other members will have a leader = 0 value. Is there a way to limit joins like this?
    your brain reacts in the same way whether you are
    looking at something or thinking about it...

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,322
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    exactly like you did, except using an INNER JOIN

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •