X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id ACF9FD1B507 for ; Mon, 15 Sep 2003 08:34:18 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 14623-09 for ; Mon, 15 Sep 2003 05:33:48 -0300 (ADT) Received: from anchor-post-37.mail.demon.net (anchor-post-37.mail.demon.net [194.217.242.87]) by svr1.postgresql.org (Postfix) with ESMTP id 83D9ED1B4EF for ; Mon, 15 Sep 2003 05:33:40 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-37.mail.demon.net with esmtp (Exim 3.35 #1) id 19yonl-00069j-0b; Mon, 15 Sep 2003 09:33:41 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 81C9516B7C; Mon, 15 Sep 2003 09:33:40 +0100 (BST) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id C01C816A7F; Mon, 15 Sep 2003 09:33:39 +0100 (BST) From: Richard Huxton To: "PipHans" , pgsql-sql@postgresql.org Subject: Re: Plz, what is the most "correct" method Date: Mon, 15 Sep 2003 09:33:38 +0100 User-Agent: KMail/1.5 References: <3f5f4af1$0$48889$edfadb0f@dtext02.news.tele.dk> In-Reply-To: <3f5f4af1$0$48889$edfadb0f@dtext02.news.tele.dk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200309150933.38978.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/131 X-Sequence-Number: 15109 On Wednesday 10 September 2003 17:01, PipHans wrote: > Table1: > id Auto,int,PrimKey > table2id int > txt nvarchar50 > > Table2: > id Auto,int,PrimKey > order int > > The scenario: Table2.order defines how the table1.txt is should be ordered. > Table1.table2id contains the id of the order. This cannot be changed > > How do I select all Table1.txt values but ordered by their corresponding > values of the table2.order field? Sorry for the delay here - are you subscribed to the list? If not that can slow things down (it only showed Monday, after you posted Wednesday). All you need to do is join the two tables and order by the required field SELECT t1.id, t1.txt FROM table1 as t1, table2 as t2 WHERE t1.table2id=t2.id ORDER BY t2.order -- Richard Huxton Archonet Ltd