The left join allows the user to pull out all sorts of interesting data based upon certain restrictions. This is an extremely powerful option of table joins, and greatly facilitates table manipulation. Now, the boss is screaming for some details. Details, details, details! It's no problem however, as the left join will solve our problem. Assume that
We now have a informative listing of all pcs ordered by our clients! Using a PHP3 or Perl script, one could see how this could be used to print out receipts, for example. We could combine this with the client table for reason of emailing the client an occasional email with a list of all products he has purchased from our company. Perhaps another useful report we could generate would involve learning of the number of pcs ordered that had product id (pid) number 3.
The Using ClauseA variation to the left join allows us to further correlate identical columns residing in multiple tables. This is the using option. Instead of the following:
We could state:
However, both would produce the same result:
There you have it. Table joins made easy. Try playing around with variations of the commands highlighted within this article to gain a clear understanding of the syntax. Once this is understood, you will find that table joins will play an integral part in your development activities. Be sure to check out MySQL's various discussion groups (http://www.mysql.com), as there is usually quite a bit of information exchanged regarding table joins.
blog comments powered by Disqus |