Logo         Community
  Trog
Services
The Company
Community
Columns
Your Account
Contact Us
 
 
Understanding SQL Joins
Left join. Right join. Inner join. Welcome to the wild, the wacky, the insanely cool world of SQL joins.

| Meeting The Family |

Before we begin, I'd like to introduce you to the three tables I'll be using in this tutorial. Say hello to table "a".

''.preg_replace(array('/  /', '/ /'), array('  ', '   '), '
+----+------+
| a1 | a2  |
+----+------+
| 10 | u    |
| 20 | v    |
| 30 | w    |
| 40 | x    |
| 50 | y    |
| 60 | z    |
+----+------+
6 rows in set (0.05 sec)
').'
'

Next up, drop by table "b",

''.preg_replace(array('/  /', '/ /'), array('  ', '   '), '
+----+------+
| b1 | b2  |
+----+------+
| 10 | p    |
| 20 | q    |
+----+------+
2 rows in set (0.06 sec)
').'
'

Finally, last but not least, table "c".

''.preg_replace(array('/  /', '/ /'), array('  ', '   '), '
+-----+------+
| c1  | c2  |
+-----+------+
|  90 | m    |
| 100 | n    |
| 110 | o    |
+-----+------+
3 rows in set (0.05 sec)
').'
'

As you can see, I spent a lot of time naming them, so I expect you to be properly appreciative of my efforts.

These tables have been constructed in MySQL 4.x, a free (and very powerful) open-source RDBMS. Due to differences in capabilities, the techniques outlined in this article may not work on other RDBMS; you should refer to the documentation that comes with each system for accurate syntax.

I've deliberately kept these tables simple, so that you have as little difficulty as possible understanding the examples. At a later stage, once the basic joins are clear to you, I'll replace these simple tables with more complex, real-world representations, so that you understand some of the more arcane applications of joins.


How to do Everything with PHP & MySQL
How to do Everything with PHP & MySQL, the best-selling book by Melonfire, explains how to take full advantage of PHP's built-in support for MySQL and link the results of database queries to Web pages. You'll get full details on PHP programming and MySQL database development, and then you'll learn to use these two cutting-edge technologies together. Easy-to-follow sample applications include a PHP online shopping cart, a MySQL order tracking system, and a PHP/MySQL news publishing system.

Read more, or grab your copy now!


previous page more like this  print this article  next page
 
Search...
 
In trog...
Logging With PHP
Building A Quick-And-Dirty PHP/MySQL Publishing System
Output Buffering With PHP
Date/Time Processing With PHP
Creating Web Calendars With The PEAR Calendar Class
more...
 
In the hitg report...
Crime Scenes
Animal Attraction
Lord Of The Strings
more...
 
In boombox...
Patience - George Michael
Think Tank - Blur
My Private Nation - Train
more...
 
In colophon...
Hostage - Robert Crais
The Dead Heart - Douglas Kennedy
Right As Rain - George Pelecanos
more...
 
In cut!...
American Chai
The Core
Possession
more...
 
Find out how you can use this article on your own Web site!


Copyright © 1998-2018 Melonfire. All rights reserved
Terms and Conditions | Feedback