Re: Joins within a table

Поиск
Список
Период
Сортировка
От Richard Broersma Jr
Тема Re: Joins within a table
Дата
Msg-id 19423.32520.qm@web31810.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на Joins within a table  (Steve Lefevre <lefevre.10@osu.edu>)
Список pgsql-novice
--- Steve Lefevre <lefevre.10@osu.edu> wrote:

> Hello all -
>
> I'm trying to do a JOIN within a table. In MySQL, I would do
>
> SELECT  main_table.field, join_table.field
> FROM main_table
> LEFT JOIN main_table AS join_table ON join_table.id = main_table.parent_id

PostgreSQL conforms to the SQL standard when it comes to giving alias names to a single table and
doesn't use MySQL's vendor specific extension:

         SELECT Instance1.field, Instance2.field
           FROM Main_table AS Instance1
LEFT OUTER JOIN Main_table AS Instance2
             ON Instance1.id = Instance2.id;

Here I am showing two alias names, but you could reduce this query to use only one if you wanted.

Regards,
Richard Broersma Jr.

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

Предыдущее
От: Steve Lefevre
Дата:
Сообщение: Joins within a table
Следующее
От: "Andrew Maclean"
Дата:
Сообщение: Re: Joins within a table