Skip site navigation (1) Skip section navigation (2)

Re: find the number of row for each tables

From: "D(dot) Duccini" <duccini(at)backpack(dot)com>
To: NRonayette <r97m10(at)socotec(dot)fr>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: find the number of row for each tables
Date: 2000-06-15 13:23:52
Message-ID: Pine.GSO.4.03.10006150821410.12453-100000@ra.bpsi.net (view raw or flat)
Thread:
Lists: pgsql-novice
Interesting, I just tried the following:

actmgr=> select count(a.id), count(b.id) from accounts a, subaccounts b;
^C
CANCEL request sent
ERROR:  Query was cancelled.
actmgr=> select count(id) from accounts;
count
-----
  781
(1 row)

actmgr=> select count(id) from subaccounts;
count
-----
 1939
(1 row)

i had to cancel the first one after about a minute, but the second two
came right back

since

actmgr=> select count(distinct a.id), count(distinct b.id) from accounts a, subaccounts b;

this doesn't work.

-duck

On Thu, 15 Jun 2000, NRonayette wrote:

> Hi everybody, 
> i try something that could work (i tested it on a Oracle base, and it
> works fine, sorry, i haven't got postgresql at my office :-((
> 
> select count(distinct (<Primary_key_of_friends>)), count(distinct
> (<Primary_key_of_strangers>))
> from Friends, Strangers
> WHERE friends.f_id = strangers.s_id AND friends.categorie = 1;
> 
> If f_id and S_id are the primary key of each table, replace
> <primary_key_of_friend> and <primary_key_of_strangers> by f_id and s_id
> respectively.
> 
> i hope this will work for you
> 
> Nicolas
> 
> Patrick Coulombe wrote:
> > 
> > > Try simply SELECT * from friends;
> > ???
> > Not working... I just want to know if it's possible to know how many rows
> > the query return for each table when i do a query with two table ie: select
> > * from table1, table2 where...
> > 
> > can i know the number of row for table1 and the number of row for table2
> > without do 2 querys.
> > 
> > thank you
> > hope to be more clear this time
> > patrick
> > 
> > > On Tue, 13 Jun 2000, Patrick Coulombe wrote:
> > >
> > > > hi,
> > > > here's the question : if I do this query on my database :
> > > >
> > > > SELECT * from friends, strangers WHERE friends.f_id = strangers.s_id AND
> > > > friends.categorie = 1
> > > > ----------
> > > > 88 rows
> > > >
> > > > and I need to do this query to know how many rows just for my table
> > friends
> > > > (not both table) :
> > > >
> > > > SELECT * from friends WHERE friends.f_id = strangers.s_id AND
> > > > friends.categorie = 1
> > > > ----------
> > > > 80 rows
> > > >
> > > >
> > > > Can I just do 1 query and be able to find the number of row for each
> > tables?
> > > > Hope to be understand...
> > > >
> > > > Patrick
> 


-----------------------------------------------------------------------------
david(at)backpack(dot)com            BackPack Software, Inc.        www.backpack.com
+1 651.645.7550 voice       "Life is an Adventure.    
+1 651.645.9798 fax            Don't forget your BackPack!"   
-----------------------------------------------------------------------------



In response to

Responses

pgsql-novice by date

Next:From: D. DucciniDate: 2000-06-15 13:25:41
Subject: Re: Maximum size before having to use BLOBs.
Previous:From: ghaverlaDate: 2000-06-15 12:21:01
Subject: Re: Maximum size before having to use BLOBs.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group