On Mon, 2002-12-09 at 20:58, Chris Jewell wrote:
> ...
> However, I now want to have a new table which converts numbers into
> words.  The problem is this, if I join the main table with the
> "translation" lookup table, the column names for each of the four
> categories in the main default to the column name in the lookup table
> and hence are all the same.  What SQL expression should I use to
> translate the cryptic numbers into plain english whilst preserving the
> column headings in the main table?

You just need to name the columns:

  SELECT t.antibiotic,
         e1.plain_english AS "Activity against grampos",
         e2.plain_english AS "Activity against gramneg",
         e3.plain_english AS "Activity against aerobes",
         e4.plain_english AS "Activity against anaerobes"
    FROM tblantibiotics AS t,
         efficacy AS e1,
         efficacy AS e2,
         efficacy AS e3,
         efficacy AS e4
   WHERE t.activity_against_grampos = e1.efficacy_code AND
         t.activity_against_gramneg = e2.efficacy_code AND
         t.activity_against_aerobes = e3.efficacy_code AND
         t.activity_against_anaerobes = e4.efficacy_code;

Note that you must use double quotes to quote identifiers, not single
quotes as you did in your table creation definitions, which won't work
in PostgreSQL.

-- 
Oliver Elphick                                [EMAIL PROTECTED]
Isle of Wight, UK                             http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "I beseech you therefore, brethren, by the mercies of 
      God, that ye present your bodies a living sacrifice, 
      holy, acceptable unto God, which is your reasonable 
      service."           Romans 12:1 


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to [EMAIL PROTECTED] so that your
message can get through to the mailing list cleanly

Reply via email to