From: | Richard Broersma <richard(dot)broersma(at)gmail(dot)com> |
---|---|
To: | Matt Foster <Matthew(dot)Foster(at)noaa(dot)gov> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Need help with OUTER JOIN |
Date: | 2011-11-18 18:15:06 |
Message-ID: | CABvLTWESKR+zVOONPN_=8mgms=5eNDuyWQ+yS=k7ACvu+CiZng@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Fri, Nov 18, 2011 at 9:44 AM, Matt Foster <Matthew(dot)Foster(at)noaa(dot)gov> wrote:
> 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';
1) Replace the USING() to ON office_list.office = verification_date.office
Find all of the columns in your WHERE clause that are in your
Verification_Data table and move these criteria to ON clause.
SELECT office_list.office, verification_data.period
FROM office_list
LEFT OUTER JOIN verification_data
ON Office_list.office = verification_data.office
AND start_time > 'yesterday'
AND start_time < 'today'
WHERE period=1
AND name='foo'
AND element='bar';
--
Regards,
Richard Broersma Jr.
From | Date | Subject | |
---|---|---|---|
Next Message | Matt Foster | 2011-11-18 18:24:30 | Re: Need help with OUTER JOIN |
Previous Message | Thom Brown | 2011-11-18 17:48:14 | Re: Need help with OUTER JOIN |