Re: noobie join question

From: Steve Clark <sclark(at)netwolves(dot)com>
To: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>, pgsql-general(at)postgresql(dot)org
Subject: Re: noobie join question
Date: 2015-05-11 13:06:43
Message-ID: 5550A963.6040103@netwolves.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 05/11/2015 07:16 AM, Oliver Elphick wrote:
> On Mon, 2015-05-11 at 06:46 -0400, Steve Clark wrote:
>> Hi List,
>> I am having trouble trying to figure out
>> how to get the result listed at the bottom.
>>
>> I have 3 tables units, types of units which has a description of the units,
>> and a table that list associations of the units. I can't figure out
>> how to do the proper joins. Any pointers would be appreciated.
> SELECT us.udevice, ts.descr, ud.udevice, td.descr
> FROM assoc AS a
> LEFT JOIN units AS us
> ON a.src_id = us.uid
> LEFT JOIN types AS ts
> ON us.utype = ts.id
> LEFT JOIN units AS ud
> ON a.dest_id = ud.uid
> LEFT JOIN types AS td
> ON ud.utype = td.id;
>
>
>
>
Thanks Oliver - that worked perfectly.

--
Stephen Clark
*NetWolves Managed Services, LLC.*
Director of Technology
Phone: 813-579-3200
Fax: 813-882-0209
Email: steve(dot)clark(at)netwolves(dot)com
http://www.netwolves.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Mogensen 2015-05-11 13:10:04 Comparing txid and xmin (under BDR)
Previous Message Daniel Begin 2015-05-11 12:38:44 Re: Restarting DB after moving to another drive