首页 > MySQL库存(store)字段为null,但是我的SQL判断了库存,导致SQL无法查询结果?

MySQL库存(store)字段为null,但是我的SQL判断了库存,导致SQL无法查询结果?

$sql = "SELECT a.image_default_id,b.product_id,b.price,b.mktprice,b.name FROM `sdb_b2c_goods` AS a 
                    INNER JOIN sdb_b2c_products AS b ON a.goods_id=b.goods_id
                    WHERE a.marketable='true' 
                    AND a.verify='1' 
                    AND a.disabled='false'
                    AND b.disabled='false'
                    AND b.store>b.freez
                    AND (b.store-b.freez)>0
                    AND b.product_id IN ($productId)
                    ORDER BY FIELD(product_id,{$productId})";

如何将store为null的时候 强制转换为int类型呢?


IFNULL(store, 0)

【热门文章】
【热门文章】