oracl 和db2 常用语法比较: 1、取前N条记录 Oracle:Select * from TableName where rownum <= N; DB2:Select * from TableName fetch first N rows only; 2、取得系统日期 Oracle:Select sysdate from dual; DB2:Select current timestamp from sysibm.sysdummy1; 3、空值转换 Oracle:Select
在mysql中使用内部函数instr,可代替传统的like方式查询,并且速度更快。
instr 函数,第一个参数是字段,第二个参数是要查询的串,返回串的位置,第一个是1,如果没找到就是0.
例如,查询字段name中带”军”的名字,传统的方法是:
select name from 用户表 where name like `%军%';
用instr的方法:
select name from 用户表 where instr('name‘,‘军');
或:
select name from 用