Select—没你想的那么复杂
上一篇 /
下一篇 2012-07-17 11:25:07
/ 个人分类:数据库
o'j#B%[1tg6]$T*v0 Select语句的基本结构如下:
_XT'tTr-n8~i0Select [All | Distinct] select_list MF$]qdB%Q0[Into [new_table-name]]51Testing软件测试网g6V f niW Form. {table_name | view_name}51Testing软件测试网0}7b{#luY [,{table_name2 | view_name2}51Testing软件测试网i9yt3T%sF$fp ….,{table_name10|view_name10}] K`+@$TJ2M"{,I0[Where search_conditions] f2D;N
wrU
d
i%Qb0[Group By group_by_list] NB%aq2`4x2@0r$S0[Having search_conditions]51Testing软件测试网tk;o6l;]/j@W [Order By order_list [ASC| DESC]] |
51Testing软件测试网#Y0W})WH
\
N1iQ 第一行语句中select_list表示需要检查的字段的列表,字段名称间用逗号分隔51Testing软件测试网(i#D#^M4J
51Testing软件测试网|/e
hf&j$R nA*B All 指明查询结果中可以显示值相同的列,且为系统默认
I7lZ4b-\e051Testing软件测试网p^m;kRy8O Distinct 指明查询结果中如有值相同的列,则只显示其中的一列51Testing软件测试网b:R3N^"G
51Testing软件测试网a EHP%H a7a 第二行语句中Into子句用于把查询结果存放到一个新建的表中
m:S%B)|Y~ t*j9V051Testing软件测试网2GpVXj#MSc`O o new_table-name 指明新建表的名称
#J
?BR(uHK06h/\"}oGk0 第三行语句中Form. 子句指定需要查询的表注:只要Select中又要查询的列就必须使用From子句51Testing软件测试网L5qf"pR hS'n
w5^wHw3Us-a#K2|'`0 table_name / view_name 指明Select 语句要用到的表,视图等数据源,该列表中的数据表名和视图名之间使用逗号分隔51Testing软件测试网+X7OHc8]p
8z['b-X9hV1BG)a\0 第四行语句中 Where子句是制定数据检索的条件,以限制返回的数据行51Testing软件测试网-T9~9\N4h3Cc