Skip site navigation (1) Skip section navigation (2)

Re: Joins within a table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Steve Lefevre <lefevre(dot)10(at)osu(dot)edu>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Joins within a table
Date: 2007-06-13 00:51:09
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
Steve Lefevre <lefevre(dot)10(at)osu(dot)edu> writes:
> 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 = main_table.parent_id

Yeah, that's the same way you'd do a self-join in Postgres.

> However, in the Postgres documentation, I don't see anything on JOIN AS. 

Where did you look?  Maybe you are confusing the alias clause with the
join clause --- they are two different constructs.

			regards, tom lane

In response to

pgsql-novice by date

Next:From: Tom LaneDate: 2007-06-13 01:14:11
Subject: Re: unreasonable run time for vacuum analyze?
Previous:From: Richard Broersma JrDate: 2007-06-13 00:25:14
Subject: Re: unreasonable run time for vacuum analyze?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group