21.10.2013 Views

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

DML statements<br />

Description: A natural join is an automatic equi-join on all the columns that exist in both relations. If there are<br />

no common column names, a CROSS JOIN is produced.<br />

Syntax:<br />

Example:<br />

Notes:<br />

SELECT ...<br />

FROM NATURAL [] JOIN <br />

...<br />

::= {table | view | cte | (select_stmt)} [[AS] alias]<br />

::= INNER | {LEFT | RIGHT | FULL} [OUTER]<br />

select * from Pupils natural left join Tutors<br />

Assuming that the Pupils and Tutors tables have two field names in common: TUTOR and CLASS,<br />

the equivalent traditional syntax is:<br />

select * from Pupils p left join Tutors t<br />

on p.tutor = t.tutor and p.class = t.class<br />

• Common columns can be selected from a natural join without qualifier. Beware, however, that doing so in<br />

outer joins doesn't always gives the same result as selecting left.colname or right.colname. One of the<br />

latter may be NULL while the other isn't; plain colname always returns the non-NULL alternative in such cases.<br />

• SELECT * from a natural join returns each common column only once. In outer joins, such a column always<br />

contains the non-NULL alternative except for rows where the field is NULL in both tables.<br />

ORDER BY<br />

Syntax:<br />

SELECT ... FROM ...<br />

...<br />

ORDER BY [, ...]<br />

::= {col-name | col-alias | col-position | expression}<br />

[COLLATE collation-name]<br />

[ASC[ENDING] | DESC[ENDING]]<br />

[NULLS {FIRST|LAST}]<br />

Order by colum alias<br />

Added in: 2.0<br />

Description: <strong>Firebird</strong> 2.0 and above support ordering by column alias.<br />

77

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!