select ziduan1+","+ziduan2 "newziduan from table1 where ziduan3 =canshu 改变标题方法: 1.select ziduan1 "newziduan" from table1; 2.select 新字段=ziduan from table1; 删除重复行: select distinct* from table //使用关键字:distinct,默认为all; 返回限制行: select top 2* from table ; select top 20 percent from table; select ziduan1 from table1 as 别名 where所使用的运算符: >,>=,=,<,<=,<>,!>,!<,between...and...,not between...and..., in(项1,项2...),not in(项1,项2...)//判断表达式是否在列表中的指定项; like,not like,is null,not is null,not,and,or; like的通配字符: %:匹配任意英文字符,中文字符为%%; _:匹配对象为单个任意字符,常用来限制表达式的字符长度; []:指定一个字符,字符串或范围,要求匹配其中的任意一个; [^]:与[]相反; order by: desc降序,asc升序; 聚合函数: AVG([ALL|DISTINCT]expression) 计算平均值 MIN(expression) 计算最小值 MAX(expression) 计算最大值 SUM([ALL|DISTINCT] expression) 总和 COUNT([ALL|DISTINCT] expression) select into 产生的表必须是数据库中不存在的; 联合查询: select语句1 UNION(select语句2 UNION select语句3); 连接查询 //待补充 case语句 case ziduan when 0 then "no" when 1 then "yes" end update语句://更新同时还清空null; 单行更新: update table1 set ziduan1=1,ziduan2=2 where id =1; 多行更新: update table1 set ziduan1="new" where type="first"; insert 语句: insert table1 values("1","2","3");//按原先的顺序; insert table1(conlumn1,conlumn2) values("1","2");//插入到指定的列; insert table1 select语句//将select查询结果插入到table1中; delete from table1 where id=1;//删除 建视图: create view 视图名[列名] as select语句 //列名可省略 drop view 视图名 create table table1(ziduan1 int,ziduan2 char(40),ziduan3 numeric(20,5)) //建表语句,其中numeric表示整数位为20,小数点位为5位的数 datetime //表示从1753年1月1日到该时间的毫秒总和 自增长ID insert into table1(column1,column2,column3) values("1","2","3") select @@IDENTITY AS"自增长ID"
posted on 2007-09-19 19:32  gerdy  阅读(295)  评论(0编辑  收藏  举报