Re: [SQL] find the number of rows for each table

2000-06-18 Thread Peter Eisentraut

Patrick Coulombe writes:

> I want to find the number of rows for each table (2) in 1 query,
> the query is:

To find the number of rows in one table you do

SELECT COUNT(*) FROM table;

To find the number of rows in two tables you send two queries like
that. There's no good way to do it in one shot, nor is there any reason
why there should: if you want two different pieces of information you send
two queries. Also note that some of your attempts are going to be wildly
slower than just two straightforward count(*) queries.

> 
> select distinct * from medias, contacts WHERE medias.media_id = 
> contacts.media_id AND medias_categories.media_id = medias.media_id AND 
> medias_categories.categorie_id = 1
> 
> 700 rows
> 
> 
> If I want to find the number of row for medias (for the same query) I 
> have to do a other query :
> 
> select distinct * from medias WHERE medias.media_id = 
> contacts.media_id AND medias_categories.media_id = medias.media_id AND 
> medias_categories.categorie_id = 1
> 
> 60 rows
> 
> 
> I search for a solution, I try that :
> 
> select distinct *, count(distinct (medias.media_id)), count(distinct 
> (contacts.contact_id)) from medias, contacts WHERE medias.media_id = 
> contacts.media_id AND medias_categories.media_id = medias.media_id AND 
> medias_categories.categorie_id = 1
> -
> ERROR:  parser: parse error at or near "distinct"
> 
> don't work, as you can see.

-- 
Peter Eisentraut  Sernanders väg 10:115
[EMAIL PROTECTED]   75262 Uppsala
http://yi.org/peter-e/Sweden




Re: [SQL] Database Transfer

2000-06-18 Thread Peter Eisentraut

Craig May writes:

> I have two servers running pgsql.  Is there a command to transfer the
> databases
> between them?

pg_dump and psql. "Back up" one database and "restore" it on the other
server. Don't even think about moving files around. :)

-- 
Peter Eisentraut  Sernanders väg 10:115
[EMAIL PROTECTED]   75262 Uppsala
http://yi.org/peter-e/Sweden




[SQL] capacity of copy command??

2000-06-18 Thread rocael

Hi All!
I just wanna now how much is the capacity of the copy command...
I did a  psql mydb < data.sql
inside data.sql I had a COPY "table" FROM stdin;
and around 200,000 registers and it gave me error message... pg_atoi... :(
but it worked inserting by parts of the file...

thanx,

Rocael.


Get free email and a permanent address at http://www.netaddress.com/?N=1