I have a database in phpmyadmin
for all my suppliers. I have created a php file that exports to csv on a daily basis the cheapest stock and quantity of each unique sku in the database. At the moment however, it is excluding any item that has no stock anywhere, however, i would like that... if there is no stock anywhere to print 0 for those items.
The original sql statement is (where name=SKU
):
SELECT name,MIN(price) AS minPrice,quantity FROM products WHERE quantity > 0 GROUP BY name
I tried already the following, but this does not work as intended:
SELECT name,MIN(price) AS minPrice,IF(quantity > 0,quantity,'0') AS quantity FROM products GROUP BY name