sql 里写条件判断
来源:

xiaowu9
2017-02-17
现在有这么个需求,在更新数据的时候,某些字段需要更新,某些不需要更新怎么写
update table set name=1,type=1 where id=1;
update table set name=1 where id=1;
update table set type=1,sex=2 where id=1;
以上三条语句怎么合成一句?
写回答
3回答
-
sqlercn
2017-02-19
如果一定要写到一个SQL中的话,就用case来实现就可以
00 -
sqlercn
2017-02-17
update table set name=1,type=1,sex=2 where id = 1 ?
042017-05-30 -
sqlercn
2017-05-31
可以使用case语句进行一下判断
012017-05-31
相似问题
索引个数
回答 2
where 条件只能用于范围查找 ?
回答 1
那么怎么让mysql利用cpu核心呢?
回答 1
课程中涉及的SQL脚本,哪里可以下载
回答 1
怎么让一个sql使用两个索引
回答 1