From: mauro.folcarelli@sistinf.it
To: pgsql-php@postgresql.org
Subject: Re: Selecting from two tables
Date: Thu, 15 Jan 2004 08:44:09 +0100
Message-ID: <OF5DA66277.51C42621-ONC1256E1C.002A6AD2@sistinf.it> (raw)
>> I have a table called Jobs and another called Applications.
>> I can query all Job rows, but how do I also include the number
>> of Application rows for each Job row in the SELECT statement?
Try this way:
(1) CREATE VIEW viewappl AS
SELECT jobid
,count(*) as numappl
FROM application
GROUP BY
jobid;
(2) SELECT
job.jobid
,job.login
,job.jobtitle
,job.jobdescrip
,job.jobkeywords
,job.valid
,job.postdate
,viewappl.numappl
FROM job , viewappl
where job.jobid = viewappl.jobid
order by
job.jobid
;
I hope it's ok.
Hi, Mauro
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-php@postgresql.org
Cc: mauro.folcarelli@sistinf.it
Subject: Re: Selecting from two tables
In-Reply-To: <OF5DA66277.51C42621-ONC1256E1C.002A6AD2@sistinf.it>
References: <OF5DA66277.51C42621-ONC1256E1C.002A6AD2@sistinf.it>
* 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