Re: LEFT JOIN problem

From: Jayadevan M <maymala(dot)jayadevan(at)gmail(dot)com>
To: Michael Rowan <michael(dot)rowan3(at)gmail(dot)com>
Cc: pgsql-novice novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: LEFT JOIN problem
Date: 2013-08-10 10:30:57
Message-ID: CAFS1N4gG3w63DA1fb5Gy9V+xaKZqneawwDTAm9NBvJ0jyc0sSg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hi,
You could have a look at these threads -
http://stackoverflow.com/questions/8779918/postgres-multiple-joins
http://www.postgresql.org/message-id/17688.988657537@sss.pgh.pa.us

Regards,
Jayadevan

On Sat, Aug 10, 2013 at 8:42 AM, Michael Rowan <michael(dot)rowan3(at)gmail(dot)com>wrote:

> Hi
> Extreme novice here. Pls be gentle. I have a database with four tables
>
> orders (have a foreign key to depots.de_id)
> depots (have a foreign key to customers.co_id)
> companies
> addresses
>
> depots have an optional cross reference from depots.de_ad_id to
> addresses.ad_id
>
> so:
>
> SELECT co_id, de_id, or_id
> FROM orders, depots, companies
> LEFT JOIN addresses ON (de_ad_id=ad_id)
> WHERE or_id=de_or_id AND co_id=de_co_id;
>
> returns error
> ERROR: invalid reference to FROM-clause entry for table "depots"
> LINE 1: ...pots, orders, companies LEFT JOIN addresses ON (depots.de_...
> ^
> HINT: There is an entry for table "depots", but it
>
> The error message is incomplete.
>
> Any idea whats wrong with my code? Thanks
>
> Mike
>
>
>

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Mael Rimbault 2013-08-10 12:58:37 Re: LEFT JOIN problem
Previous Message Michael Rowan 2013-08-10 03:12:10 LEFT JOIN problem