From vs0u8055@liv.ac.uk Mon Dec 9 21:01:15 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 7E60A476476 for ; Mon, 9 Dec 2002 16:01:15 -0500 (EST) Received: from mta06-svc.ntlworld.com (mta06-svc.ntlworld.com [62.253.162.46]) by postgresql.org (Postfix) with ESMTP id 40D7947630B for ; Mon, 9 Dec 2002 15:58:46 -0500 (EST) Received: from linux.chrisdomain ([81.97.70.23]) by mta06-svc.ntlworld.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20021209205844.BNPI495.mta06-svc.ntlworld.com@linux.chrisdomain> for ; Mon, 9 Dec 2002 20:58:44 +0000 Received: from chris (chris.chrisdomain [192.168.1.35]) by linux.chrisdomain (8.11.0/8.11.6) with SMTP id gB9KcIm01426 for ; Mon, 9 Dec 2002 20:38:18 GMT Message-ID: <000f01c29fc5$afc34960$2301a8c0@chrisdomain> Reply-To: "Chris Jewell" From: "Chris Jewell" To: Subject: Problem with a lookup table! Please help. Date: Mon, 9 Dec 2002 20:58:12 -0000 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_000C_01C29FC5.AF8025E0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/104 X-Sequence-Number: 10692 This is a multi-part message in MIME format. ------=_NextPart_000_000C_01C29FC5.AF8025E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, In my capacity as a vet student, I'm trying to create a database of antibio= tics. The way that I have set it up so far is to have one main table listi= ng the antibiotics versus their respective efficacies against the four majo= r groups of bacteria. Due to the way that my PHP frontend works, I have as= signed a number to the efficacy - 1 being excellent and 5 being poor effica= cy against the particular bacterium. However, I now want to have a new tab= le which converts numbers into words. The problem is this, if I join the m= ain 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 t= able and hence are all the same. What SQL expression should I use to trans= late the cryptic numbers into plain english whilst preserving the column he= adings in the main table? Regards, Chris J ------=_NextPart_000_000C_01C29FC5.AF8025E0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi,
 
In my capacity as a vet student, I'm tryin= g to=20 create a database of antibiotics.  The way that I have set it up so fa= r is=20 to have one main table listing the antibiotics versus their respective=20 efficacies against the four major groups of bacteria.  Due to the way = that=20 my PHP frontend works, I have assigned a number to the efficacy - 1 being= =20 excellent and 5 being poor efficacy against the particular bacterium. = =20 However, I now want to have a new table which converts numbers into words.&= nbsp;=20 The problem is this, if I join the main table with the "translation" lookup= =20 table, the column names for each of the four categories in the main default= to=20 the column name in the lookup table and hence are all the same.  What = SQL=20 expression should I use to translate the cryptic numbers into plain english= =20 whilst preserving the column headings in the main table?
 
Regards,
 
Chris J
------=_NextPart_000_000C_01C29FC5.AF8025E0-- From josh@agliodbs.com Mon Dec 9 21:11:15 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D0A57476309 for ; Mon, 9 Dec 2002 16:11:15 -0500 (EST) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id 38FEA476586 for ; Mon, 9 Dec 2002 16:05:05 -0500 (EST) Received: from [66.219.92.2] (HELO chocolate-mousse) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2273664; Mon, 09 Dec 2002 13:05:07 -0800 Content-Type: text/plain; charset="iso-8859-1" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "Chris Jewell" , Subject: Re: Problem with a lookup table! Please help. Date: Mon, 9 Dec 2002 13:08:34 -0800 X-Mailer: KMail [version 1.4] References: <000f01c29fc5$afc34960$2301a8c0@chrisdomain> In-Reply-To: <000f01c29fc5$afc34960$2301a8c0@chrisdomain> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200212091308.34332.josh@agliodbs.com> X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/106 X-Sequence-Number: 10694 Chris, > In my capacity as a vet student, I'm trying to create a database of=20 antibiotics. The way that I have set it up so far is to have one main tabl= e=20 listing the antibiotics versus their respective efficacies against the four= =20 major groups of bacteria. Due to the way that my PHP frontend works, I hav= e=20 assigned a number to the efficacy - 1 being excellent and 5 being poor=20 efficacy against the particular bacterium. However, I now want to have a n= ew=20 table which converts numbers into words. The problem is this, if I join th= e=20 main table with the "translation" lookup table, the column names for each o= f=20 the four categories in the main default to the column name in the lookup=20 table and hence are all the same. What SQL expression should I use to=20 translate the cryptic numbers into plain english whilst preserving the colu= mn=20 headings in the main table? Please post your table definitions as SQL statements. --=20 -Josh Berkus Aglio Database Solutions San Francisco From jllachan@nsd.ca Mon Dec 9 21:46:34 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id D57A847658F for ; Mon, 9 Dec 2002 16:46:34 -0500 (EST) Received: from beamish.nsd.ca (unknown [205.150.156.194]) by postgresql.org (Postfix) with ESMTP id C9FC44764B4 for ; Mon, 9 Dec 2002 16:35:02 -0500 (EST) Received: (from smap@localhost) by beamish.nsd.ca (8.9.3/8.9.3) id QAA17510; Mon, 9 Dec 2002 16:34:57 -0500 X-Authentication-Warning: beamish.nsd.ca: smap set sender to using -f Received: from reddog.nsd.ca(192.168.101.30) by beamish.nsd.ca via smap (V2.1/2.1+anti-relay+anti-spam) id xma017508; Mon, 9 Dec 02 16:34:32 -0500 Received: from nsd.ca (jllachan-linux.nsd.ca [192.168.101.148]) by reddog.nsd.ca (8.8.7/8.8.7) with ESMTP id QAA18472; Mon, 9 Dec 2002 16:33:06 -0500 Message-ID: <3DF50C6E.2D94936D@nsd.ca> Date: Mon, 09 Dec 2002 16:34:38 -0500 From: Jean-Luc Lachance X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.9-31 i686) X-Accept-Language: en MIME-Version: 1.0 To: josh@agliodbs.com Cc: Chris Jewell , pgsql-sql@postgresql.org Subject: Re: Problem with a lookup table! Please help. References: <000f01c29fc5$afc34960$2301a8c0@chrisdomain> <200212091308.34332.josh@agliodbs.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/107 X-Sequence-Number: 10695 Use the AS keyword to introduce a column alias. Select thisverlongtablename.thefirstfield as title, ... from JLL Josh Berkus wrote: > > Chris, > > > In my capacity as a vet student, I'm trying to create a database of > antibiotics. The way that I have set it up so far is to have one main table > listing the antibiotics versus their respective efficacies against the four > major groups of bacteria. Due to the way that my PHP frontend works, I have > assigned a number to the efficacy - 1 being excellent and 5 being poor > efficacy against the particular bacterium. 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? > > Please post your table definitions as SQL statements. > > -- > -Josh Berkus > Aglio Database Solutions > San Francisco > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) From vs0u8055@liv.ac.uk Mon Dec 9 22:35:33 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 10382476637 for ; Mon, 9 Dec 2002 17:35:33 -0500 (EST) Received: from mta07-svc.ntlworld.com (mta07-svc.ntlworld.com [62.253.162.47]) by postgresql.org (Postfix) with ESMTP id 7B36B47663F for ; Mon, 9 Dec 2002 17:22:11 -0500 (EST) Received: from linux.chrisdomain ([81.97.70.23]) by mta07-svc.ntlworld.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20021209222212.GYZM9037.mta07-svc.ntlworld.com@linux.chrisdomain> for ; Mon, 9 Dec 2002 22:22:12 +0000 Received: from chris (chris.chrisdomain [192.168.1.35]) by linux.chrisdomain (8.11.0/8.11.6) with SMTP id gB9M1vm01478 for ; Mon, 9 Dec 2002 22:01:57 GMT Message-ID: <001201c29fd1$5a50ef30$2301a8c0@chrisdomain> Reply-To: "Chris Jewell" From: "Chris Jewell" To: References: <000f01c29fc5$afc34960$2301a8c0@chrisdomain> <200212091308.34332.josh@agliodbs.com> Subject: Re: Problem with a lookup table! Please help. Date: Mon, 9 Dec 2002 22:21:42 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/108 X-Sequence-Number: 10696 Hi, Thanks for your reply. Table definitions are: CREATE TABLE tblantibiotics ('Antibiotic' varchar(50),'Activity_against_grampos' int,'Activity_against_gramneg' int,'Activity_against_aerobes' int,'Activity_against_anaerobes' int); CREATE TABLE efficacy ('Efficacy_code' int,'Plain_english' varchar (10)); In table efficacy, 'Efficacy_code' contains a 1 - 5 scale of efficacy. Each string in 'Plain_english' is a plain English descriptor of the value in 'Efficacy_code'. For example, 1 => Excellent, 2=> Good, etc etc. What I need to do is to substitute the integers set in the "Activity......." columns in tblantibiotics with the strings in 'Plain_english' according to the integer set in 'Efficacy_code'. Any ideas? Chris J ----- Original Message ----- From: "Josh Berkus" To: "Chris Jewell" ; Sent: Monday, December 09, 2002 9:08 PM Subject: Re: [SQL] Problem with a lookup table! Please help. Chris, > In my capacity as a vet student, I'm trying to create a database of antibiotics. The way that I have set it up so far is to have one main table listing the antibiotics versus their respective efficacies against the four major groups of bacteria. Due to the way that my PHP frontend works, I have assigned a number to the efficacy - 1 being excellent and 5 being poor efficacy against the particular bacterium. 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? Please post your table definitions as SQL statements. -- -Josh Berkus Aglio Database Solutions San Francisco From olly@lfix.co.uk Tue Dec 10 02:08:40 2002 Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8AD0E47639A for ; Mon, 9 Dec 2002 21:08:40 -0500 (EST) Received: from anchor-post-33.mail.demon.net (anchor-post-33.mail.demon.net [194.217.242.91]) by postgresql.org (Postfix) with ESMTP id 16B18476609 for ; Mon, 9 Dec 2002 21:07:52 -0500 (EST) Received: from lfix.demon.co.uk ([158.152.59.127] helo=linda.lfix.co.uk) by anchor-post-33.mail.demon.net with esmtp (Exim 3.35 #1) id 18LZoR-000PTN-0X; Tue, 10 Dec 2002 02:07:55 +0000 Received: from localhost ([127.0.0.1] ident=olly) by linda.lfix.co.uk with esmtp (Exim 3.36 #1 (Debian)) id 18LZoQ-0005bU-00; Tue, 10 Dec 2002 02:07:54 +0000 Subject: Re: Problem with a lookup table! Please help. From: Oliver Elphick To: Chris Jewell Cc: pgsql-sql@postgresql.org In-Reply-To: <000f01c29fc5$afc34960$2301a8c0@chrisdomain> References: <000f01c29fc5$afc34960$2301a8c0@chrisdomain> Content-Type: text/plain Organization: LFIX Limited Message-Id: <1039486074.20146.43.camel@linda.lfix.co.uk> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.0 Date: 10 Dec 2002 02:07:54 +0000 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/110 X-Sequence-Number: 10698 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 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 present your bodies a living sacrifice, holy, acceptable unto God, which is your reasonable service." Romans 12:1