pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Patrick Coulombe <pcoulombe@mediacces.com>
To: pgsql-sql@postgresql.org
Subject: find the number of rows for each table
Date: Thu, 15 Jun 2000 20:10:36 +0000 (GMT)
Message-ID: <20000615.20103600@modemcable079.96-200-24.mtl.mc.videotron.net> (raw)

Hi,

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

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.



I need help, please.
Patrick






view thread (2+ messages)  latest in thread

Message-ID: <20000615.20103600@modemcable079.96-200-24.mtl.mc.videotron.net>
Permalink:  ../20000615.20103600@modemcable079.96-200-24.mtl.mc.videotron.net/
Also on:    postgresql.org/message-id/20000615.20103600@modemcable079.96-200-24.mtl.mc.videotron.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: pcoulombe@mediacces.com
  Subject: Re: find the number of rows for each table
  In-Reply-To: <20000615.20103600@modemcable079.96-200-24.mtl.mc.videotron.net>
  References: <20000615.20103600@modemcable079.96-200-24.mtl.mc.videotron.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox