Browse Search  
Home :MySQL :

Select statement to join tables?
Category : MySQL
 
 
For a simple join:

SELECT a.*, b.*
FROM tblAlpha a, tblBeta b
WHERE (a.keyfield = b.foreignkey);

It's often smarter to do an outer join, especially if you need rows in 
tblAlpha to show up in your resultset even if there is no matching 
record in tblBeta:

SELECT a.*, b.*
FROM tblAlpha a LEFT OUTER JOIN tblBeta b
 ON a.keyfield = b.foreignkey;

If you want to get into the nuts and bolts of it, the MySQL doc is 
found at:
http://www.mysql.com/doc/en/JOIN.html
 
 
This article has been viewed 678 times.



ASPWebHosting.com.au Copyright © 2004-2005 | All Rights Reserved |

All trademarks are property of their legal owners.