Received: from mailout06.sul.t-online.de (mailout06.sul.t-online.com [194.25.134.19]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f8F7mY754080 for ; Sat, 15 Sep 2001 03:48:34 -0400 (EDT) (envelope-from A_Schnabel@t-online.de) Received: from fwd01.sul.t-online.de by mailout06.sul.t-online.de with smtp id 15iABj-0004Zv-01; Sat, 15 Sep 2001 09:48:31 +0200 Received: from taska (520019441306-0001@[217.80.134.138]) by fwd01.sul.t-online.com with smtp id 15iABi-1xfJcuC; Sat, 15 Sep 2001 09:48:30 +0200 Message-ID: <006501c13dba$ab8954c0$0201a8c0@aschnabel.homeip.net> From: A_Schnabel@t-online.de (Andre Schnabel) To: "trebischt" , References: Subject: Re: To query many tables. Date: Sat, 15 Sep 2001 09:47:28 +0200 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 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Sender: 520019441306-0001@t-dialin.net X-Archive-Number: 200109/87 X-Sequence-Number: 4751 ----- Original Message ----- From: "trebischt" Subject: [SQL] To query many tables. > Hi, > > The query looks like this: > > select * from table1 f, table2 s, table3 t, table4 fo, table5 fi, > table6 si, table 7 se, table8 e, table9 n, table10 ten, table 11 el, > table 12 tw ... > where f.id=s.id > and f.id=t.id > and f.id=fo.id > and f.id=fi.id > and so on... > > Is this the right way, or are there any better solution? > How do the professionals make that big queries? Yes, this is ONE right way. Professionals do it the same way ;-). But you can use the "JOIN"-Clause instead. It's your desicion, what's more readable. With JOIN it would look like this: select * FROM table1 f JOIN table2 s ON f.id = s.id JOIN table 3 t ON f.id = t.id .... more joins here .... WHERE xxx If you use your way or this simple joins, there must be a row with the same id in each table, to have it shown by your query. If you want to see all records, that have an entry in at least one table you have to use outer joins. More details on SELECT statemants and joins are here: http://www.postgresql.org/idocs/index.php?queries.html. Andre