
SQL语句集锦
热
【字体:小 大】
SQL语句集锦
作者:- 文章来源:- 点击数:9382 更新时间:2006-4-14 
Top
回复人: cloud1002(好得掉渣~) ( ) 信誉:100 2003-3-19 9:35:06 得分:0
mark
Top
回复人: smallmuda(飞翔的猪) ( ) 信誉:101 2003-3-19 9:37:27 得分:0
select * from a where time between time1 and time2
Top
回复人: yonghengdizhen(刹那←→永恒) ( ) 信誉:112 2003-3-19 9:40:15 得分:0
让你们看看什么是SQL经典吧..
http://expert.csdn.net/Expert/TopicView1.asp?id=928809
Top
回复人: cpp2017(幕白兄) ( ) 信誉:145 2003-3-19 9:41:08 得分:5
select isNull(A.name,B.name),isnull(a.code,B.code) from table1 A
full out join table2 B on
A.id = B.id
Top
回复人: yonghengdizhen(刹那←→永恒) ( ) 信誉:112 2003-3-19 9:43:29 得分:0
to cpp2017(长安不见使人愁)
jeff?
Top
回复人: zhw_yihui(卜卢特) ( ) 信誉:94 2003-3-19 9:53:25 得分:0
SQL:SELECT NEWID()
Top
回复人: yonghengdizhen(刹那←→永恒) ( ) 信誉:112 2003-3-19 9:58:59 得分:0
select a,b,c from tablename ta where a=(select max(a) from tablename tb where tb.b=ta.b)
选择在每一组b值相同的数据中对应的a最大的(换成average或别的函数或子查询,你会有意想不到的发现)记录的所有信息.
类似这样的用法可以用于论坛每月排行榜,每月热销产品分析,按科目成绩排名,等等.
上面的许多同志对子查询存在有偏见与误解,其实在一个好的数据分析程序中,子查询可以简化很多程序逻辑.
Top
回复人: yonghengdizhen(刹那←→永恒) ( ) 信誉:112 2003-3-19 10:01:40 得分:0
上面select a,b,c from tablename ta where a=(select max(a) from tablename tb where tb.b=ta.b)
这种相关子查询和delete(insert)等结合起来,可以用于消除数据库中某个字段(或某些)的重复值
Top
回复人: hubinasm(火星撞地球) ( ) 信誉:115 2003-3-19 10:10:41 得分:0
(select a from tableA ) except (select a from tableB) except (select a from tableC)
Top
回复人: aocool(知秋一叶) ( ) 信誉:100 2003-3-19 10:14:11 得分:0
[8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] [26] [27] [28] [29] [30] [31] [32] [33] [34] [35] [36] [37] [38] [39] [40] [41] [42] [43] [44] [45] [46] [47] [48] [49] [50]
