Re: Problem with a lookup table! Please help.
От | Oliver Elphick |
---|---|
Тема | Re: Problem with a lookup table! Please help. |
Дата | |
Msg-id | 1039486074.20146.43.camel@linda.lfix.co.uk обсуждение исходный текст |
Ответ на | Problem with a lookup table! Please help. ("Chris Jewell" <vs0u8055@liv.ac.uk>) |
Список | pgsql-sql |
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 againstgramneg", 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, efficacyAS e4 WHERE t.activity_against_grampos = e1.efficacy_code AND t.activity_against_gramneg = e2.efficacy_codeAND 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 Oliver.Elphick@lfix.co.uk 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 presentyour bodies a living sacrifice, holy, acceptable unto God, which is your reasonable service." Romans 12:1
В списке pgsql-sql по дате отправления: