List:General Discussion« Previous MessageNext Message »
From:Peter Brawley Date:May 23 2006 2:05pm
Subject:Re: I think I need a join
View as plain text  
Critters wrote:

 >I can get it to join on either countryA or countryB but not both :|

SELECT
  d.id, d.day,
  c1.country, c1.id,
  c2.country, c2.id
FROM days d
INNER JOIN countries c1 ON d.countryA = c1.id
INNER JOIN countries c2 ON d.countryB = c2.id
ORDER BY d.id

(Getting ready for the World Cup?)

PB

-----
> I think the following could be done with some sort of JOIN, but I am 
> now sure how:
>
>
>
> [country]:
> id, country, number
> 1, Germany, 27
> 2, Japan, 30
> 3, United States, 18
>
> [days]
> id, day, countryA, countryB
> 10, monday, 1, 3
> 11, tuesday, 2, 3
> 12, wednesday, 1, 2
>
> [result I want]
> 10, monday, Germany, 27, United States, 18
> 11, tuesday, Japan, 30, United States, 18
> 12, wednesday, Germany, 27, Japan, 30
>
> Hope that makes sence :)
>
> I can get it to join on either countryA or countryB but not both :|
> -- 
> David
>


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.392 / Virus Database: 268.7.0/345 - Release Date: 5/22/2006

Thread
InnoDB problems under 5.1.9Ben Clewett23 May
  • RE: InnoDB problems under 5.1.9SST - Adelaide)23 May
    • Re: InnoDB problems under 5.1.9Ben Clewett23 May
      • RE: InnoDB problems under 5.1.9SST - Adelaide)23 May
        • Re: InnoDB problems under 5.1.9Ben Clewett23 May
        • I think I need a joinCritters23 May
          • Re: I think I need a joinPeter Brawley23 May
    • How do I get off this list that I do not remember joining in the first place!!!!Phil Robbins25 May
      • Re: How do I get off this list that I do not remember joining inthe first place!!!!Daniel Kasak25 May
        • Re: How do I get off this list that I do not remember joining in the firstplace!!!!Phil Robbins26 May
          • Re: How do I get off this list that I do not remember joining inthe first place!!!!James Harvard26 May
          • Re: How do I get off this list that I do not remember joining inthe first place!!!!Daniel Kasak26 May
      • RE: How do I get off this list that I do not remember joining in the first place!!!!Tim Lucia25 May
  • Re: InnoDB problems under 5.1.9gerald_clark23 May
    • Re: InnoDB problems under 5.1.9Ben Clewett23 May
    • Re: InnoDB problems under 5.1.9Ben Clewett23 May
      • Re: InnoDB problems under 5.1.9Dan Buettner23 May
        • Re: InnoDB problems under 5.1.9Ben Clewett23 May
          • Re: InnoDB problems under 5.1.9Dan Buettner23 May
            • Re: InnoDB problems under 5.1.9Ben Clewett23 May
            • Re: InnoDB problems under 5.1.9Ben Clewett23 May