select [distinct] [top n] *| 字段1 as 别名1 ,字段2 as 别名2 ,from 表1,表2 [where 条件 ] [group by 字段 [having 条件] ] [order by 字段 [asc] [desc ] ];
distinct (字段数据去重)
top n 前 n 条记录
where 条件 where 字段=“条件”
where 字段 in (“条件1”,“条件2”)
where 字段 like " *条件* "
where 字段 between 1000 and 2000
where 字段 > 1000 and | or <2000
[group by 字段 [having 条件]
例: having avg (工资) >1000
分组设条件 用 having 不用where
<,> ,=,<=,>=,<> ,mod ,^ null, not null
多表查询 注意表间关系
select 表1.表1字段1 as 别名1 ,表1.表1字段2 as 别名2 ,表2.表2字段1from 表1,表2 where 表1.表1字段 = 表2.表2字段 [group by ][order by];
子查询 select 字段1 as 别名1 ,字段2 as 别名2 ,from 表1, where 字段 = “条件” and any |all |(select from 表1 where 。。。)
union
身份证号取年龄
岁: DateDiff("yyyy", DateSerial(Mid([身份证号],7,4),Mid([身份证号],11,2),Mid([身份证号],13,2)),Now())