SQL Server MySQL 中的 in 与 null
2015-06-27 13:38
489 查看
例子:
create table t(x int,y int);
insert into t(x,y) values(1,1),(2,2),(null,null);
查询一:
select x,y from t where x in (1,2,null);#它并不会返回null的行哦
查询二:
select * from t where x=1 or x=2 or x=null -- 说明 in 只是多个 or = 的语法糖衣吧。
查询三:如果要真正的返回null行,可以这样做
select * from t where x in (1,2) or x is null
create table t(x int,y int);
insert into t(x,y) values(1,1),(2,2),(null,null);
查询一:
select x,y from t where x in (1,2,null);#它并不会返回null的行哦
查询二:
select * from t where x=1 or x=2 or x=null -- 说明 in 只是多个 or = 的语法糖衣吧。
查询三:如果要真正的返回null行,可以这样做
select * from t where x in (1,2) or x is null
相关文章推荐
- mysql int(3)与int(11)的区别
- Mac下启动和停止Mysql服务
- Mysql触发器
- 解决ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
- MySQL错误代码大全
- mysql之日期函数
- MySql Host is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' 解决方法
- Mysql中如何将时间戳转化为常用日期格式
- mysql中Where条件中字段顺序的重要性
- 使用各种查询选择来提高性能
- 上课笔记第三十二天MySQL服务器日志、备份和恢复
- JDBC,MySQL
- mysql 定时任务
- Windows Server 2008R2配置MySQL Cluster并将管理节点和数据节点配置成windows服务
- MySQL ALTER TABLE: ALTER vs CHANGE vs MODIFY COLUMN 2014-07-03 14:13:11
- mysqldump导出SQL出现乱码解决
- Mysql常用操作
- 2种方法解决mysql主从不同步
- Mac下的Mysql无法登陆的问题
- MySQL导入Emoji表情符号报错