1、说明:复制表(只复制结构,源表名:a 新表名:b) (Access可用) 法一:select * into b from a where 11(仅用于SQlServer)* w# w9 z* v& a: ]
法二:select top 0 * into b from a& e3 f* h& J1 z3 e- K
2、说明:拷贝表(拷贝数据,源表名:a 目标表名:b) (Access可用)5 a- t4 K3 J# w& W
insert into b(a, b, c) select d,e,f from b;4 e' L( g) C* v R( A7 G6 {
3、说明:跨数据库之间表的拷贝(具体数据使用绝对路径) (Access可用)
T/ Z: H1 B! X$ K) D. d insert into b(a, b, c) select d,e,f from b in ‘具体数据库’ where 条件, k! R3 R( `5 s" I7 N0 V Q
例子:..from b in '"&Server.MapPath(".")&"\data.mdb" &"' where..
7 D7 ]* e) a" J+ V$ o 4、说明:子查询(表名1:a 表名2:b): t, v" M1 y+ i/ z; G) d. b
select a,b,c from a where a IN (select d from b ) 或者: select a,b,c from a where a IN (1,2,3)0 a& I* Y, t3 _: n
5、说明:显示文章、提交人和最后回复时间
" r% C/ u5 B3 |1 |' x! e" p/ r8 } select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where table.title=a.title) b$ T* ~: U j, Q( z. D: K
6、说明:外连接查询(表名1:a 表名2:b)
9 Q1 s8 q; U% p5 E2 E v; c- z select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c O; x$ L" w& q' j" j' r
7、说明:在线视图查询(表名1:a )
]. t, o: L$ J; K# | ]0 a select * from (SELECT a,b,c FROM a) T where t.a > 1;$ n! ~+ t! j- X/ w% X+ Q% d2 D2 N- `9 H, r
8、说明:between的用法,between限制查询数据范围时包括了边界值,not between不包括
5 `. v3 v$ V8 D4 i/ s# Z8 K0 J select * from table1 where time between time1 and time2
/ t6 e d5 a; G7 K8 e. f
- O1 z4 q6 p* M5 x2 _ select a,b,c, from table1 where a not between 数值1 and 数值2 |