SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    relationship with join and select

    Hello

    I am very confused and frustrated here. What relationship does the columns in SELECT have with the actual JOIN query.

    Ive got these three tables in my SELECT
    dbUsers.*, dbPosts.*, dbKarma.*

    but when I add a fourth table
    dbUsers.*, dbPosts.*, dbKarma.*, dbPosts_share.*

    the whole query stops outputting results.

    What relationship does the SELECT have with the JOIN query?
    Why would this effect the query?
    As far as I know, SELECT is for the actual output in the loop?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,260
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by Jaynesh View Post
    the whole query stops outputting results.
    most likely because of either (1) a syntax error, or (2) an implicit cross join which returns a bazillion rows, and the query never finishes executing

    Quote Originally Posted by Jaynesh View Post
    What relationship does the SELECT have with the JOIN query?
    it determines which column(s) are to be returned from the join

    Quote Originally Posted by Jaynesh View Post
    Why would this effect the query?
    it wouldn't

    Quote Originally Posted by Jaynesh View Post
    As far as I know, SELECT is for the actual output in the loop?
    there is no such thing as a loop in mysql, but i think you have the right idea, the SELECT determines which columns are to be returned
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi.

    What would happen if I added a table that is not in the join?
    Is it expected to work?

  4. #4
    SitePoint Addict
    Join Date
    Sep 2006
    Posts
    238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just did an SQL query in PhpMyAdmin with an additional table in the SELECT which is in my join query but I get an error saying "unknown table" why is this happening?

  5. #5
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,025
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    Can you post the structure of the tables concerned and the query that you've got so far?
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  6. #6
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,260
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by Jaynesh View Post
    I just did an SQL query in PhpMyAdmin with an additional table in the SELECT which is in my join query but I get an error saying "unknown table" why is this happening?
    without seeing the query, and without knowing which tables you actually have, i would only be guessing

    if you want help, you have to give us more to go on...
    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
  •