Results 1 to 4 of 4
  1. #1
    Join Date
    May 2003
    Posts
    2

    Question Unanswered: Double Inner Join

    I am trying to get data from two tables, however, data needs to match the criteria from the second table twice.

    Code:
    SELECT reviews.*, companies.id, companies.url, companies.name
    FROM (reviews INNER JOIN companies ON companies.id = reviews.publisher)
    INNER JOIN companies AS companiesTmp ON companies.id = reviews.developer
    WHERE reviews.id = " . $id
    I hope this makes sense.

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    did you want only those reviews where the publisher and the developer are the same company? or do you want all reviews plus the publisher company plus the developer company?

    rudy
    http://rudy.ca/

  3. #3
    Join Date
    May 2003
    Posts
    2
    Originally posted by r937
    did you want only those reviews where the publisher and the developer are the same company? or do you want all reviews plus the publisher company plus the developer company?

    rudy
    http://rudy.ca/
    The reviews where the review is equal to the review that was selected. The review is selected on a previous page and the id is passed to this page where I am pulling everything that is associated to that review. Problem arises that it specifies the company id and then pulls the company info needed. This would be where it could pull from two different rows.

    Review was published by company A(3) and developed by company B(2). It would then select the company information from the companies table for A and B, whether they are the same company or not.

    Make sense?

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    select reviews.*
         , pub.url, pub.name
         , dev.url, dev.name
      from (
           reviews 
    inner join companies pub
        on reviews.publisher = pub.id
           )
    inner join companies dev 
        on reviews.developer = dev.id
     where reviews.id = $id

Posting Permissions

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