Date: 11/11/00
- Next message: Enrico Comini: "[PHP-DB] How many users"
- Previous message: Chris Sano: "[PHP-DB] mySQL commands in PHP"
- In reply to: Chris Lee: "[PHP-DB] MySQL SELECT help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
>see thats fine, but now what I want is if there are no entries in one of
>the tables to still return the data it knows about. ie.
>
>select * from product
>================
>1234 truck
>
>select * from product_category
>========================
>1234 automobile
>
>select * from product_image
>======================
>Empty Set
>
>select * from product, product_category, product_image
>============================================
>1234 truck 1234 automobile NULL NULL
>
>
>Can this be done ?
A LEFT JOIN preserves the left table, i.e. it returns all the rows in
the left table. You have to decide which table is going to be your
left table, and then you can do
FROM (left_table LEFT JOIN another_table) LEFT JOIN remaining_table
ON <list of join conditions>
This will give you all the rows from left_table with any matching
rows from the other two tables, or NULLs when there's no matching
rows.
Every image has to have a product, but not every product has to have
an image. Every product has to have a category, but not every
category has to have a product. So I would guess that you want
product_category as your left table.
Bob Hall
Know thyself? Absurd direction!
Bubbles bear no introspection. -Khushhal Khan Khatak
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe <email protected> For additional commands, e-mail: php-db-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Enrico Comini: "[PHP-DB] How many users"
- Previous message: Chris Sano: "[PHP-DB] mySQL commands in PHP"
- In reply to: Chris Lee: "[PHP-DB] MySQL SELECT help"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

