Need help with OUTER JOIN - Mailing list pgsql-novice

From Matt Foster
Subject Need help with OUTER JOIN
Date
Msg-id 4EC69961.5080303@noaa.gov
Whole thread Raw
Responses Re: Need help with OUTER JOIN  (Thom Brown <thom@linux.com>)
Re: Need help with OUTER JOIN  (Richard Broersma <richard.broersma@gmail.com>)
List pgsql-novice
I'm having trouble getting the desired results from an OUTER JOIN, and
I'm hoping I can get some help here.

My first table, office_list, has a column, office, that is a static list
of all field office identifiers in our area.  The second table,
verification_data, contains data that is submitted daily by the field
offices.  The verification_data table contains columns for the office ID
(also office), a timestamp (start_time), and other various data.  I'm
needing to perform a query that will always give me a complete list of
offices (i.e. everything from the first table), plus a field from the
second table, and is also conditional on the timestamp and a few other
tests.

Here is what I have been trying, unsuccessfully...

SELECT office_list.office, verification_data.period
FROM office_list
LEFT OUTER JOIN verification_data USING (office)
WHERE start_time > 'yesterday'
AND start_time < 'today'
AND period=1
AND name='foo'
AND element='bar';

The result is that I only get rows where there are matches between the
two tables.

Where have I gone awry?

Thanks!

Matt

--
Do not go where the path may lead; go instead where there is no path and leave a trail.
-- Ralph Waldo Emerson


Attachment

pgsql-novice by date:

Previous
From: "Daniel Staal"
Date:
Subject: Re: Real novice question: Roles
Next
From: Phil Dobbin
Date:
Subject: Re: Real novice question: Roles