List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:August 20 1999 2:52pm
Subject:Re: Multiple joins query
View as plain text  
On Fri, 1999-08-20 10:27:31 -0400, Wayne Spivak wrote:
> I have a table called addresses.  It contains four fields for Area,
> (called area, area_1, so on).
> 
> I have another table called Area, which contains two fields, areano
> & areaname.
> 
> My problem is how do I produce output substituting the areaname for
> each area.  (I can do one without a problem - not rocket science
> here).

  SELECT t0.areaname AS areaname,
       , t1.areaname AS areaname_1,
       , t2.areaname AS areaname_2,
       , t3.areaname AS areaname_3
  FROM   addresses AS a
       , Area      AS t0
       , Area      AS t1
       , Area      AS t2
       , Area      AS t3
  WHERE a.area   = t0.areano
    AND a.area_1 = t1.areano
    AND a.area_2 = t2.areano
    AND a.area_3 = t3.areano
  ;

This should do it, I hope (typed off the cuff).

Regards,
  Martin
-- 
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7
Thread
Multiple joins queryWayne Spivak20 Aug
  • Re: Multiple joins queryMartin Ramsch20 Aug