SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2009
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What is faster, left join or 2 queries?

    Is it almost always faster to use left join insted of using to have 2 queries? I need to display user (firstname, lastname, image and hobbies). First 3 data are from the same table, hobbies are in other table.

    I presume that in this case left join is much better, am I right? And what is in generall a better choice?

  2. #2
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,180
    Mentioned
    65 Post(s)
    Tagged
    2 Thread(s)
    Well, I see no reason to not use a join in the query. Otherwise you'll have to mess with doing so in your php code, correct?

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,247
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    i can think of one scenario where the join is not advised... Minimize Bandwith in One-to-Many Joins

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

  4. #4
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by r937 View Post
    i can think of one scenario where the join is not advised... Minimize Bandwith in One-to-Many Joins

    Wow, I never thought of using UNIONS like that. I'll have to scour that site to see if there are more handy tricks


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
  •