Sql实现更新的时候判断是否为某个值再更新
sql解析:这里是判断是否为null和空字符串,是就不更新,不是就更新
1 2 3 4 5 6 7 |
UPDATE sys_user SET user_name = IF ( user_name IS NULL OR LENGTH( user_name )= 0, user_name, '54354' ) WHERE sys_user.id = 8; |
sql解析:这里是判断是否为null和空字符串,是就不更新,不是就更新
1 2 3 4 5 6 7 |
UPDATE sys_user SET user_name = IF ( user_name IS NULL OR LENGTH( user_name )= 0, user_name, '54354' ) WHERE sys_user.id = 8; |