X-Original-To: pgsql-sql@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 8B0C3475AA9 for ; Sun, 6 Apr 2003 14:06:08 -0400 (EDT) Received: from davinci.ethosmedia.com (unknown [209.10.40.251]) by postgresql.org (Postfix) with ESMTP id D3D8E4758E6 for ; Sun, 6 Apr 2003 14:06:07 -0400 (EDT) Received: from [63.195.55.98] (HELO temoku) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 2947309; Sun, 06 Apr 2003 11:06:01 -0700 Content-Type: text/plain; charset="big5" From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: "CN" , pgsql-sql@postgresql.org Subject: Re: Extraordinary Full Join Date: Sun, 6 Apr 2003 10:05:58 -0700 User-Agent: KMail/1.4.3 References: <20030406055017.6E7054FDFB@smtp.us2.messagingengine.com> In-Reply-To: <20030406055017.6E7054FDFB@smtp.us2.messagingengine.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200304061005.58820.josh@agliodbs.com> X-Spam-Status: No, hits=-32.4 required=5.0 tests=BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_KMAIL autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/83 X-Sequence-Number: 12784 CN: > Even better, if possible, "sort" book and hobby column descendently to > fill up null columns: >=20 > id | name | book | hobby > ----+------+--------+------- > m1 | John | book1 |hobby1 > m1 | John | book2 |hobby2 >=20 > What is the better-have SQL to produce the last furnished list? You'll need to add an "sort_no" column to both tbook and thobby, and ensure= =20 somehow that both tables have the exact same sequence of sort numbers. The= n=20 you can: select tmaster.id, tmaster.name, tbook.book, thobby.hobby from tmaster, tbook, thobbby where tmaster.id =3D tbook.id=20 and tmaster.id =3D thobby.id and tbook.sort_no =3D thobby.sort_no order by name, tbook.sort_no There would also be ways for you to account for having a different number o= f=20 books or hobbies, but that would be a much more complex query. --=20 -Josh Berkus Aglio Database Solutions San Francisco