Mysql null (空) 等于空和不等于空的使用

1 . Mysql update 更新的条件当中判断某个字段的值等于空的使用

例如下面是判断:在sales_flat_creditmemo 表中 如果base_am_amount_total_refunded 的值为(等于)空(NULL),则更改new_order_id 和store_credit_used 这两个字段的值为空(NULL)

UPDATE sales_flat_creditmemo SET `new_order_id`= NULL,`store_credit_used`= NULL  WHERE  base_am_amount_total_refunded IS NULL;

2 . Mysql select 查询的条件当中判断某个字段的值等于空的使用 ( is null)

SELECT  `entity_id`,`order_id`,`transaction_id`,`base_am_amount_total_refunded`,`am_amount_total_refunded`,`new_order_id`,`store_credit_used`FROM  sales_flat_creditmemo  WHERE  transaction_id IS NULL ;

3 . Mysql select 查询的条件当中判断某个字段的值不等于空的使用 (is not null)

SELECT  `entity_id`,`order_id`,`transaction_id`,`base_am_amount_total_refunded`,`am_amount_total_refunded`,`new_order_id`,`store_credit_used`FROM  sales_flat_creditmemo  WHERE  transaction_id IS NOT  NULL ;

.

Leave a comment

您的电子邮箱地址不会被公开。 必填项已用 * 标注