docs:mysql:joins

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

docs:mysql:joins [2007/03/26 00:22] – created billhdocs:mysql:joins [2008/08/03 00:25] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +====== JOINS ====== 
 +===== outer joins using more than 2 tables ===== 
 +Show all rows from table parcels, and only those from the other two tables that match the join criteria (the order makes a difference): 
 +<code mysql> 
 +SELECT parcels.*, areas.code, areas.desc, 
 + owneralts.owner AS altowner, 
 + owneralts.address as altaddress, 
 + owneralts.city as altcity, 
 + owneralts.state as altstate, 
 + owneralts.zip as altzip, 
 + owneralts.phone as altphone, 
 + owneralts.comments as altcomments  
 + FROM owneralts  
 + RIGHT JOIN areas  
 + RIGHT JOIN parcels  
 + ON areas.id=parcels.area  
 + ON owneralts.owner_id=parcels.alternate_owner_id 
 + WHERE 1; 
 +</code>