Re: IFNULL
| From: | Chris | Date: | Sun, 14 Feb 2010 22:30:04 +0000 |
| Subject: | Re: IFNULL | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-46886@lists.php.net to get a copy of this message | ||
Ron Piggott wrote:
How do I add " IFNULL " to the LEFT JOIN query? I either want the result from the database or a 0 instead of the word NULL Ron SELECTYou don't add it to the join, it goes on a field you're selecting. select IFNULL(inventory.inventory, 0) AS blah, .... -- Postgresql & php tutorials http://www.designmagick.com/store_product_profile.reference, inventory.inventory, sold_1.quantity, sold_2.quantity, sold_3.quantity FROMstore_product_profileLEFT JOIN ( SELECTstore_product_inventory_control.store_product_profile_reference, SUM(store_product_inventory_control.quantity) AS inventory FROMstore_product_inventory_controlGROUP BYstore_product_inventory_control.store_product_profile_reference) AS inventory ONstore_product_profile.reference=inventory.store_product_profile_reference