From: | sql(at)hayes(dot)ch (Simon Hayes) |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: How Two JOINS from one table |
Date: | 2004-08-09 13:18:21 |
Message-ID: | 60cd0137.0408090518.1aa94881@posting.google.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
ree <ree(at)hotmail(dot)coom> wrote in message news:<Xns9540C069A4F5Areehotmailcoom(at)211(dot)29(dot)133(dot)50>...
> I got this problem where I need to look up values in two columns from
> another table.
>
> I can get OUTER LEFT JOIN working when looking up one column from a table
> but when looking up at two columns from a table I can't get the SQL syntax
> correct.
>
> The scenario is
> A table has definitions for abbreviation of initials. From my search query
> there are two columns of initials, I am having problems in writing an SQL
> statement to look up and replace both columns of initials with their
> correct definitions. I was using an OUTER LEFT JOIN statement
>
>
> I am sorry if this isnt the correct Newsgroup to post this.
Without DDL, sample data and expected results this is a complete guess
(using MSSQL syntax):
update
dbo.MyTable
set
col1 = isnull(a.Definition,col1),
col2 = isnull(b.Definition,col2)
from
dbo.MyTable t
left outer join dbo.Abbreviations a
on t.col1 = a.Abbreviation
left outer join dbo.Abbreviations b
on t.col2 = b.Abbreviation
Simon
From | Date | Subject | |
---|---|---|---|
Next Message | zhicheng wang | 2004-08-09 13:18:34 | Re: postgresql and smp linux kernel |
Previous Message | Jeff Davis | 2004-08-09 12:57:17 | Re: Embedded Database |