-- t1 and t2 are tables. -- The result shows fields from -- both t1 and t2 together in a single record. SELECT * FROM t1 LEFT JOIN t2 ON (t2.a=t1.a);
Even when you want only one record, you can define a set of joined records and add a WHERE clause to pick out the one you want. SQL will be clever. It will not actually construct the set. That is just how it works conceptually.
You can compose inner joins without even using an explicit JOIN keyword.
SELECT weather.city, weather.temp_lo, weather.temp_hi, weather.prcp, weather.date, cities.location FROM weather, cities WHERE cities.name = weather.city;
Consider tables of authors and quotations. Each author may have many quotations, but each quotation can have only one author. Which table should be A or B, or does it make any difference? I suspect it does not matter. The engine can figure out which is better on its own. I would hope the engine would be smart enough to fetch the quotation record first then find the corresponding author, rather than trying to find all the quotes for each author. You can always try it both ways.
This page is posted |
http://mindprod.com/jgloss/join.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\join.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[3.12.73.149] |
| |
Feedback |
You are visitor number | |