[PHP] LEFT JOIN problems From: Chris Lee (lee <email protected>)
Date: 11/15/00

If I have three tables, purely for demonstration

t1 ID name
123 truck

t2 ID img
123 1.jpg
123 2.jpg
123 3.jpg

t3 ID cat
123 auto

SELECT * FROM t1, t2, t3;
ID name ID img ID cat
123 truck 123 1.jpg 123 auto
123 truck 123 2.jpg 123 auto
123 truck 123 3.jpg 123 auto
123 truck 123 4.jpg 123 auto

now this is all fine, but as you know if any of the tables are empty
then we have a problem, no results will be returned.

SELECT * FROM t1, t2 left join t3 using (ID);

I can use a left join, this will fix the case where there are no images.
but what if the product has no image or categories?

SELECT * FROM t1 left join t2 using (ID) left join t3 using (ID);

This will work now. under a few cases.
-All tables have info
-t1 has data, t2 has data, and t3 doesn't

but... mysql doesnt work like I want it to and places NULL in t3's
variables if t2 has no data. it doesnt matter whats in t3, if t2 has
nothing in it, then Im hooped.

Chris Lee

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe <email protected>
For additional commands, e-mail: php-general-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>