Re: How Two JOINS from one table
| От | sql@hayes.ch (Simon Hayes) |
|---|---|
| Тема | Re: How Two JOINS from one table |
| Дата | |
| Msg-id | 60cd0137.0408090518.1aa94881@posting.google.com обсуждение исходный текст |
| Ответ на | How Two JOINS from one table (ree <ree@hotmail.coom>) |
| Список | pgsql-general |
ree <ree@hotmail.coom> wrote in message news:<Xns9540C069A4F5Areehotmailcoom@211.29.133.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
В списке pgsql-general по дате отправления: