MySQL中if的写法
关键词:IF
--if 判断,如果 device_num 的值为1,则赋值为100,反之为200 SELECT district, shop_name, IF ( device_num = 1, 100, 200 ) AS device_num FROM `t_life_shop`
关键词:CASE
-- CASE WHEN(新增一个字段type值为,如果group_id = 1则type=1,如果group_id = 10则type=3,反之type=2) SELECT uid, user_name, group_id, ( CASE WHEN group_id = 1 THEN 1 WHEN group_id = 10 THEN 3 ELSE 2 END ) AS type FROM t_sys_user;
-----END
影子是一个会撒谎的精灵,它在虚空中流浪和等待被发现之间;在存在与不存在之间....