mysql问题积累示例
2014-03-05 14:28
295 查看
1.mysql 查询字段为空用is null。
select * from drqq where advice_id is null;
2.修改mysql的字段为空用null
update drqq set
advice_id=null where id='9';
3.mysql查询不为null的数据
select * from drlist
where advice_id is not null;
4.mysql的单行注释用#
5.mysql将null转换为0
select
name,ifnull(sum(visitstate=0),0) as pv0 from work
6.mysql将null转换掉
model.Dqq =
Convert.IsDBNull(dr["dqq"]).ToString();
model.Visitstate =
Convert.ToInt32(Convert.IsDBNull(dr["visitstate"]));
//去除null
7.mysql创建多表视图
drop view
work;//删除视图
create view work
as
select
advice.name,advice.relation,advice.type,advice.dltstate,drqq.dqq,patient.visitstate
from advice
left join drqq on drqq.advice_id=advice.id
left join patient on patient.dr_id=drqq.id;//创建视图
8.mysql视图查询
select name,count(distinct dqq) as dsum,count(visitstate) as
psum,ifnull(sum(visitstate=0),0) as pv0,ifnull(sum(visitstate=1),0)
as pv1 from work
where relation=3 and type=4 and dltstate=1
group by name;
select * from drqq where advice_id is null;
2.修改mysql的字段为空用null
update drqq set
advice_id=null where id='9';
3.mysql查询不为null的数据
select * from drlist
where advice_id is not null;
4.mysql的单行注释用#
5.mysql将null转换为0
select
name,ifnull(sum(visitstate=0),0) as pv0 from work
6.mysql将null转换掉
model.Dqq =
Convert.IsDBNull(dr["dqq"]).ToString();
model.Visitstate =
Convert.ToInt32(Convert.IsDBNull(dr["visitstate"]));
//去除null
7.mysql创建多表视图
drop view
work;//删除视图
create view work
as
select
advice.name,advice.relation,advice.type,advice.dltstate,drqq.dqq,patient.visitstate
from advice
left join drqq on drqq.advice_id=advice.id
left join patient on patient.dr_id=drqq.id;//创建视图
8.mysql视图查询
select name,count(distinct dqq) as dsum,count(visitstate) as
psum,ifnull(sum(visitstate=0),0) as pv0,ifnull(sum(visitstate=1),0)
as pv1 from work
where relation=3 and type=4 and dltstate=1
group by name;
相关文章推荐
- MySQL问题解决积累
- Mysql导入官方示例employees问题解决记录
- mysql 开发进阶篇系列 13 锁问题(关于表锁,死锁示例,锁等待设置)
- MySql问题积累
- Mysql导入官方示例employees问题解决记录
- 让mysql在linux下忽略大小写的问题
- 解决MySQL Sending data导致查询很慢问题的方法与思路
- 解决mysql上传附件大小问题
- PHP+MySQL Smarty简单分页显示示例
- 解决ubuntu下mysql不能远程连接数据库的问题
- Mysql5.6 + Python 3.3遇到问题“ImportError: No module named 'mysql.connector'; mysql is not a package”
- 关于QT,C++,MySQL之间中文乱码问题的简单解决
- 解决 PHP Mysql 和 UTF8的问题
- 怎样解决MySQL 5.0.16的乱码问题
- 解决win7下安装Mysql卡在Start service的问题
- mysql 常见问题
- mysql安装过程中start service失败问题
- Mysql学习中遇到的一些问题
- 导入mysql报错问题
- Docker安装MySQL忽略大小写问题的问题