Wednesday, June 6, 2007

RIGHT JOIN

The same as a left join but the table order is changed.

Returns all the rows from the second table, even if there are no matches in the first table.

This is a good means of find elements in one table but not in another.

Syntax:

SELECT field1, field2, field3, ... fieldN
FROM first_table
RIGHT JOIN second_table
ON first_table.keyfield = second_table.foreign_keyfield;

(see http://www.w3schools.com/sql/sql_join.asp)

No comments: