Re: [HACKERS] Enhancing PGSQL to be compatible with Informix SQL

From: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
To: Don Baccus <dhogaza(at)pacifier(dot)com>
Cc: "Ansley, Michael" <Michael(dot)Ansley(at)intec(dot)co(dot)za>, "'The Hermit Hacker '" <scrappy(at)hub(dot)org>, "'Bruce Momjian '" <pgman(at)candle(dot)pha(dot)pa(dot)us>, "'Rod Chamberlin '" <rod(at)querix(dot)com>, "'pgsql-hackers(at)postgreSQL(dot)org '" <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: [HACKERS] Enhancing PGSQL to be compatible with Informix SQL
Date: 2000-01-07 06:56:40
Message-ID: 38758E28.D2806B32@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> >SELECT blah, blah, blah
> >FROM t1, t2, t3, t4
> >WHERE t1.start_date BETWEEN t2.start_date (+) AND t2.end_date (+)
> >AND t1.y = t2.y (+)
> >AND t3.x (+) = t1.x
> >AND t3.y (+) = t1.y
> >AND t4.x = t1.x;
> I think the ANSI SQL 92 equivalent is something like:
> select ...
> from t1 inner join t4 on t1.x=t4.x,
> t2 left outer join t1
> on t2.y=t1.y and
> (t1.start_date between t2.start_date and t1.start_date),
> t3 left outer join t1 on t3.x=t1.x and t3.y = t1.y;

Hmm. I'm not sure what the Oracle example actually gives as a result,
and I find the syntax as confusing as others find SQL92 syntax ;)

> I've never used an ANSI SQL 92 compliant RDBMS, I'm not sure
> if t2/t1 become ambiguous and need to be given different names
> using "as foo" in each case, etc. Actually, you would in
> order to build the target list unambiguously I guess...

Once two tables are mentioned in an "outer join", then individual
columns can no longer be qualified by the original table names.
Instead, you are allowed to put table and column aliases on the join
expression:

select a, b, c, z
from (t1 left join t2 using (x)) as j1 (a, b, c)
right join t3 on (j1.a = t3.y);

(I think I have this right; I'm doing it from memory and have been
away from it for a little while).

- Thomas

--
Thomas Lockhart lockhart(at)alumni(dot)caltech(dot)edu
South Pasadena, California

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ansley, Michael 2000-01-07 07:06:23 RE: [HACKERS] Enhancing PGSQL to be compatible with Informix SQL
Previous Message Thomas Lockhart 2000-01-07 06:47:46 Re: [HACKERS] Enhancing PGSQL to be compatible with InformixSQL