X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4691ED1B437 for ; Sat, 3 Jan 2004 03:25:37 +0000 (GMT) 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 00819-10 for ; Fri, 2 Jan 2004 23:24:56 -0400 (AST) Received: from sccrmhc13.comcast.net (sccrmhc13.comcast.net [204.127.202.64]) by svr1.postgresql.org (Postfix) with ESMTP id 7C6CFD1C941 for ; Fri, 2 Jan 2004 22:55:31 -0400 (AST) Received: from andy2 (c-24-1-39-92.client.comcast.net[24.1.39.92]) by comcast.net (sccrmhc13) with SMTP id <20040103025530016008ukmme>; Sat, 3 Jan 2004 02:55:30 +0000 From: "Andy Lewis" To: "'Michael Glaesemann'" Cc: Subject: Re: sort by on two columns Date: Fri, 2 Jan 2004 20:55:30 -0600 Message-ID: <003a01c3d1a5$0cb603d0$0201a8c0@andy2> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 In-reply-to: <2E86574A-3D96-11D8-A298-000A95C88220@myrealbox.com> Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/12 X-Sequence-Number: 16405 Hi Michael, Yes, I understand this but, I would like to have the results of both "table1.name, table2.name" sorted as one column. Is this possible? Thanks, Andy -----Original Message----- From: Michael Glaesemann [mailto:grzm@myrealbox.com] Sent: Friday, January 02, 2004 8:40 PM To: Andy Lewis Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] sort by on two columns Hi Andy, On Jan 2, 2004, at 7:15 PM, Andy Lewis wrote: > Is it possible to sort by two columns? Using the query below? > > SELECT table1.name, table2.name, FROM table1, > table2 WHERE table1.id = table2.id ORDER BY > > I want to be able to sort the names select from two different tables > and > two different colums(same data type). If you want to order by table1.name and table2.name, just enter them in a comma-separated-list after ORDER BY, e.g., SELECT table1.name, table2.name, FROM table1, table2 WHERE table1.id = table2.id ORDER BY table1.name, table2.name Check out the following link for the online docs: It doesn't explicitly give you an example of sorting on more than one column, but the syntax explanation at the top includes it. Does this help? Michael Glaesemann grzm myrealbox com