syntax of outer join in 7.1devel
syntax of outer join in 7.1devel
От:
"Poul L. Christiansen" <poulc@cs.auc.dk>
Дата:
Hi
I just grabbed the latest development version from the CVS, because i need the outer join functionality.
But how do I make an outer join?
What's the syntax?
I will RTFM if someone points me to the docs :-)
Poul L. Christiansen
Re: syntax of outer join in 7.1devel
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Poul L. Christiansen" writes:
> But how do I make an outer join?
> What's the syntax?
> I will RTFM if someone points me to the docs :-)
I'm afraid I haven't updated the FM yet :-( ... but you could look at
the examples in the JOIN regress test, src/test/regress/sql/join.sql.
Or, from the SQL92 spec, here's the grammar:
::= FROM Re: syntax of outer join in 7.1devel
От:
"Poul L. Christiansen" <poulc@cs.auc.dk>
Дата:
Using the example: SELECT '' AS "xxx", * FROM J1_TBL LEFT OUTER JOIN J2_TBL USING (i); ..doesn't work because the columns which I am using to join the tables don't have the same name. How do i specify the columns if they don't have the same name? Poul L. Christiansen Tom Lane wrote:"Poul L. Christiansen" <poulc@cs.auc.dk> writes: But how do I make an outer join?= What's the syntax?I will RTFM if someone points me to the docs :-)= I'm afraid I haven't updated the FM yet :-( .= .. but you could look atthe examples in the JOIN regress test, src/test= /regress/sql/join.sql.Or, from the SQL92 spec, here's the grammar:<= br> <from clause> ::=3D FROM <table reference> [ { = <comma> <table reference> }... ] <table refe= rence> ::=3D <table name> [ [ AS ] <correlat= ion name> [ <left paren> <derived column= list> <right paren> ] ] | <derived table> = [ AS ] <correlation name> [ <left paren>= <derived column list> <right paren> ] | <j= oined table> <derived table> ::=3D <table subqu= ery> <derived column list> ::=3D <column name l= ist> <column name list> ::=3D <= ;column name> [ { <comma> <column name> }...
Re: syntax of outer join in 7.1devel
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Poul L. Christiansen" writes: > Using the example:
> SELECT '' AS "xxx", *
> FROM J1_TBL LEFT OUTER JOIN J2_TBL USING (i);
>
> ..doesn't work because the columns which I am using to join the tables don't > have the same name. How do i specify the columns if they don't have the same > name?
USING is just for the simple case where you want to join on identically- named columns. (In the even simpler case where you want to join on all identically-named columns, just say NATURAL JOIN.) Whenever you need something more complicated, you say ON some-condition, eg SELECT '' AS "xxx", * FROM J1_TBL LEFT OUTER JOIN J2_TBL ON j1_tbl.x = j2_tbl.y Note that unlike USING and NATURAL, an ON-condition doesn't cause columns to be omitted from the join result. So in the above example you'd see both x and y as output columns. > Poul L. Christiansen
>
> Tom Lane wrote:
>>ap=3D"">"Poul L. Christiansen" ailto:poulc@cs.auc.dk"><poulc@cs.auc.dk> writes:>>But how do I make an outer join?= >
What's the syntax?
I will RTFM if someone points me to the docs :-)= >
I'm afraid I haven't updated the FM yet :-( .= > .. but you could look at
the examples in the JOIN regress test, src/test= > /regress/sql/join.sql.
Or, from the SQL92 spec, here's the grammar:<= br>
<from clause> ::=3D FROM <table reference> [ { = > <comma> <table reference> }... ]
<table refe= > rence> ::=3D
<table name> [ [ AS ] <correlat= > ion name>
[ <left paren> <derived column= > list> <right paren> ] ]
| <derived table> = > [ AS ] <correlation name>
[ <left paren>= > <derived column list> <right paren> ]
| <j= > oined table>
<derived table> ::=3D <table subqu= > ery>
<derived column list> ::=3D <column name l= > ist>
<column name list> ::=3D
<= > ;column name> [ { <comma> <column name> }... >
> BTW, would you PLEASE turn off the HTML option in your mail program? regards, tom lane
Re: syntax of outer join in 7.1devel
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
See the updated FAQ on our web site for syntax. [ text/html is unsupported, treating like TEXT/PLAIN ] > Using the example:
> SELECT '' AS "xxx", *
> FROM J1_TBL LEFT OUTER JOIN J2_TBL USING (i);
>
> ..doesn't work because the columns which I am using to join the tables don't > have the same name. How do i specify the columns if they don't have the same > name?
>
> Poul L. Christiansen
>
> Tom Lane wrote:
>>"Poul L. Christiansen" <poulc@cs.auc.dk> writes:>>But how do I make an outer join?
What's the syntax?
I will RTFM if someone points me to the docs :-)
I'm afraid I haven't updated the FM yet :-( ... but you could look at
the examples in the JOIN regress test, src/test/regress/sql/join.sql.
Or, from the SQL92 spec, here's the grammar:
<from clause> ::= FROM <table reference> [ { <comma> <table reference> }... ]
<table reference> ::=
<table name> [ [ AS ] <correlation name>
[ <left paren> <derived column list> <right paren> ] ]
| <derived table> [ AS ] <correlation name>
[ <left paren> <derived column list> <right paren> ]
| <joined table>
<derived table> ::= <table subquery>
<derived column list> ::= <column name list>
<column name list> ::=
<column name> [ { <comma> <column name> }... >
> > > > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026