SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2003
    Location
    Boston
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Difficulty with JOIN query

    Is there any way through the query that I can distinguish between multiple "person_firstname" and multiple "person_lastname"? For instance, when I have multiple authors for an article.
    Code:
            $sql="SELECT
                    article_title, article_intro, article_quote, article_body, DATE_FORMAT(article_published,'%m-%d-%y') AS article_date, person_firstname, person_lastname
                  FROM
                    article, person, authorlookup
    	      WHERE
    	        article_url_name = '".$url."'
    	      AND
    	        authorlookup.article_id = article.article_id
    	      AND
    		authorlookup.person_id = person.person_id";
    thanks for any help!
    -Lewis

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    how did you want to distinguish them?

    from the looks of it, you have a one-to-many relationship,
    so multiple authors would come back as multiple rows

    which is as it should be
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2003
    Location
    Boston
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think my question pertains more to PHP. Thank you for your reply.
    -Lewis


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
  •