need some help with the following statement. i'm trying to use it to detect from my database if there is more than ONE row where sku='$sku' AND inStock='yes' ie.
ROW SKU inStock
1 1234 yes
2 1234 yes
3 1234 no
In this case it will return rows 1 & 2, but not 3 as it is listed as not in stock.
Am I close?
ROW SKU inStock
1 1234 yes
2 1234 yes
3 1234 no
In this case it will return rows 1 & 2, but not 3 as it is listed as not in stock.
Code:
SELECT sku,inStock,COUNT(*) as total FROM products WHERE sku='$sku' AND inStock='yes' GROUP BY sku,inStock HAVING total > 1 ORDER BY search, save
Comment