mysql select 通过判断type 给两个字段赋值
问题描述:
例如 type 值有1、2
用select sql语句实现
if(type=1){
left = "123123";
}
if(type=2){
right = "123qwe";
}
答
update 表名 set 字段 = IF(type=1, '123123', '123qwe')
答
select if(type=1,'123123','') as left,if(type=2,'123qwe','') as right from 表;