Re: Right Join Question

Поиск
Список
Период
Сортировка
От Scott Marlowe
Тема Re: Right Join Question
Дата
Msg-id dcc563d10910221606t26d1b55cp956193f0aaca27dd@mail.gmail.com
обсуждение исходный текст
Ответ на Right Join Question  ("Bierbryer, Andrew" <abierbryer@klsdiversified.com>)
Ответы Re: Right Join Question
Список pgsql-general
On Thu, Oct 22, 2009 at 12:43 PM, Bierbryer, Andrew
<abierbryer@klsdiversified.com> wrote:
> I am trying to solve the following problem. I have a certain column,
> to_state, that can take a finite set of values. I want to make sure that my
> query always returns those sets of finite values, even if not all of the
> values are represented in the results. In essence, I am looking to expand
> the result returned by the query by using a right join.
>
> When I do the following simple query, this seems to work.
>
> create table hat (the_hat integer);
> insert into hat values (1),(2),(3);
> create table cat (the_hat integer);
> insert into cat values (2),(3),(4),(5);
>
> select the_hat from hat
> right join cat c using(the_hat)
>
> The right join changes the results query from 1,2,3 to 2,3,4,5.

A right join will return all the rows on the right that aren't removed
by the where clause, and add the rows on the left that match, and
return nulls for those values where there is no match.

Perhaps you want a left join here?

В списке pgsql-general по дате отправления:

Предыдущее
От: Yaroslav Tykhiy
Дата:
Сообщение: Re: Reversing flow of WAL shipping
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: question about pg_dump