一.搜索前几条数据
1.DB2用法
select xx from table fetch first 5 rows only;
2.Oracle用法
select xx from table where ROWNUM<=5;
3.mysql、PostgreSQL、sqllite用法
select xx from table limit 5
二、不匹配检查
1.select xx from table where xx<>'aa01';
字段是数字类型的,不加引号,只有字符串类型的需要加
<>与!=可以互换
<>也可以与NOT互换,NOT是否定跟在后面的条件(select xx from table where not xxx='aa01')
三、空值检查
列不含值时,表示是空值
找到有空值的数据:select xx from table where xx is null
NULL,无值,与字段包含0,空字符串或仅仅包含空格不同
四、优先级
()比关键之AND、OR优先级高。
五、通配符
like可以匹配任意多个,_只能匹配单个字符
方括号[]通配符:匹配[]里的任意一个字符
select xx from table where xx like '[JM]%',%通配符第一个字符之后的任意书面字符,返回所需结果。
通配符否定用前缀字符^(脱字号):
select xx from table where xx like '[^JM]%'