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