X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 01E26D1B4A0 for ; Tue, 27 Apr 2004 09:06:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 46220-09 for ; Tue, 27 Apr 2004 09:06:44 -0300 (ADT) Received: from anchor-post-31.mail.demon.net (anchor-post-31.mail.demon.net [194.217.242.89]) by svr1.postgresql.org (Postfix) with ESMTP id 432FCD1B48A for ; Tue, 27 Apr 2004 09:06:41 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-31.mail.demon.net with esmtp (Exim 3.35 #1) id 1BIRMJ-000Fue-0V; Tue, 27 Apr 2004 13:06:44 +0100 Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id E4E2E15977; Tue, 27 Apr 2004 13:06:42 +0100 (BST) From: Richard Huxton To: blake@shopwhatcom.com (Blake), pgsql-sql@postgresql.org Subject: Re: Proper SQL syntax requested Date: Tue, 27 Apr 2004 13:06:42 +0100 User-Agent: KMail/1.5 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200404271306.42790.dev@archonet.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200404/297 X-Sequence-Number: 17672 On Thursday 22 April 2004 00:41, Blake wrote: > > Select * from floors Where system = 1 ORDER by make > > This sorts by the Serial ID's in column make > > I would like to be able to sort by the actual Names associated back > from the ID's. Anyway of doing this?? You don't say which table contains the name in question. Assuming we want column make_name from table make_description with an id of make_id then: SELECT floors.* FROM floors, make_description WHERE system=1 AND floors.make = make_description.make_id ORDER BY make_description.make_name; This is called a join. Any book on databases/SQL should discuss this sort of stuff. -- Richard Huxton Archonet Ltd