1、復制表(只復制結構,源表名:a 新表名:b)
SQL Server:select * into b from a where 1<>1
Access:select top 0 * into b from a
2、拷貝表(拷貝數(shù)據(jù),源表名:a 目標表名:b) (Access可用)
insert into b(a, b, c) select d,e,f from b;
3、跨數(shù)據(jù)庫之間表的拷貝(具體數(shù)據(jù)使用絕對路徑) (Access可用)
insert into b(a, b, c) select d,e,f from b in ‘具體數(shù)據(jù)庫’ where 條件
insert into b(a, b, c) select d,e,f from b in "&Server.MapPath(".")&"\data.mdb" &" where 條件
4、子查詢(表名1:a 表名2: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)
5、顯示文章、提交人和最后回復時間
select a.title,a.username,b.adddate from table a,(select max(adddate) adddate from table where table.title=a.title) b
6、外連接查詢(表名1:a 表名2:b)
select a.a, a.b, a.c, b.c, b.d, b.f from a LEFT OUT JOIN b ON a.a = b.c
7、在線視圖查詢(表名1:a )