`
davidxiaozhi
  • 浏览: 237240 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

SQl Cookbook学习笔记

阅读更多

1.select  * from A where a.a='a';

  执行顺序 先执行 from 在执行 where 中的东西 ,最后执行 select

2.列值连接 db2 oracle ||  , mysql concat(column1,'sss',column2) sqlServler使用+连接;

3. case when  表达式 then ''

            when  表达式 then ''

             else    ''

   end

4. 限制返回的行数

 在oracle中使用rownum <= n 限制行数

 在db2中使用fetch first 5 rows only

 注意 oracle中如果使用rownum =5 是得不到第五行的,因为oracle的查询原理获取一行后赋给行号,如果行号满足条件返回否则舍弃,这样永远得不到第五行,永远是第一行号并接舍弃,所以要想得到第五行,必须得到前四行,所以查询前五行必须是<= 5;

5.null 要想判断值是否为null必须为 is null  , null不能用等于=和不等于<> 和任何值比较包括null

6。按模式查询 like '%a' 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics