Received: from resy5.fzk.de ([141.52.68.8]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f8R7IQh24199 for ; Thu, 27 Sep 2001 03:18:28 -0400 (EDT) (envelope-from ch@rodos.fzk.de) Received: by rodos.fzk.de with ESMTP (8.8.6 (PHNE_17135)/8.7.1) id JAA03044; Thu, 27 Sep 2001 09:18:27 +0200 (METDST) From: Haller Christoph Message-Id: <200109270717.JAA23391@rodos> Subject: Re: is it possible to get the number of rows of a table? To: fklauschen@yahoo.com (Frederick Klauschen) Date: Thu, 27 Sep 2001 9:17:03 METDST Cc: pgsql-sql@postgresql.org In-Reply-To: <20010926151432.46962.qmail@web10105.mail.yahoo.com>; from "Frederick Klauschen" at Sep 26, 101 5:36 pm X-Mailer: Elm [revision: 212.4] X-Archive-Number: 200109/235 X-Sequence-Number: 4917 > > I would like to compare the number of rows > of one table and of another and use it in > a query like this: > SELECT * FROM xxxx > WHERE "number of rows of table xxxx" > EQUALS > "number of rows of table yyyy" > i.e. I only want get a query result if the tables > have the same number of rows. > Is there a function or a way to do this ? > > Thanks, > Frederick > Basically, the way to find out about the number of rows of a table is "select count(*) from t1" But the select statement above looks odd to me (no offence intended). To receive a selection of certain rows of a table you have to reference at least one column of that table in the where clause like in "select * from table1 t1 where t1.c1 = (select count(*) from t2)" I hope this helps at least a bit. Regards, Christoph