trouble: joining more than 2 tables
| From: | Blade | Date: | Thu, 19 Jun 2003 18:52:12 +0000 |
| Subject: | trouble: joining more than 2 tables | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-28749@lists.php.net to get a copy of this message | ||
Hello,
I am having a little trouble with joining more that two tables.
I can join two tables but once I start to add more tables to the WHERE
clause only two records show up.
I am still pretty new to MySQL, but I am learing. I am just stuck on this
one in hopes someone will show me the light.
I tried reading the manual and used there samples but this is as far as I
got and seems to work but only some what.
Here is my query I am trying to use in DreamweaverMX (this one pulls up only
2 records, I have seven records for test purpose):
-SELECT instockID, instock.materialCode, instock.treatmentCode,
instock.bulkCode, instock.shapeCode, instock.calibrate, instock.price,
-material.materialName, material.sDiscription, material.matImage1,
-shape.shapeName, bulk.bulkName, treatment.treatmentName
-
-FROM instock, material, shape, bulk, treatment
-
-WHERE instock.materialCode = 'colname' AND
-instock.shapeCode = shape.shapeCode AND
-instock.bulkCode = bulk.bulkCode AND
-instock.treatmentCode = treatment.treatmentCode AND
-instock.materialCode = material.materialCode
-
-ORDER BY instock.shapeCode ASC
This one I can pull all seven records but I need more information from the
other tables that is related to the instock table.
-SELECT instock.instockID, instock.materialCode, instock.treatmentCode,
instock.bulkCode, instock.shapeCode, instock.calibrate, instock.price,
-material.materialName, material.sDiscription, material.matImage1
-
-FROM instock, material
-
-WHERE instock.materialCode = 'colname' AND
-instock.materialCode = material.materialCode AND
-instock.shapeCode = shape.shapeCode
-
-ORDER BY instock.shapeCode ASC
Could someone help me and show me an other way in writting the top queries.
Thanks,
David