随笔分类 -  SQL

摘要:1 Create PROCEDURE [dbo].[up_DataPager] 2 @tblName varchar(255), -- 表名 3 @fldName varchar(255), -- 排序的字段名,一般为唯一标识 4 @strGetFields varchar(1000) = ' * ', -- 需要返回的列 5 @PageSize int = 10, -- 每页有多少条记录 6 @PageIndex int = 1, -- 第几页 7 @Count int output, -- 返回记录总数 8 @OrderType bit = ... 阅读全文
posted @ 2012-08-14 23:59 colyn 阅读(257) 评论(0) 推荐(0)
摘要:1、取不重复的工资信息 Select distinct salary from table1 注:distinct是对整个结果集进行重复处理的,而不是针对每一个列。 如distinct后有多列,则是针对多列,不是单列 例:select distinct salary,sName from table12、在表中新加一列 alter table table1 add colum varchar(20) null;3、Union select name,password from table1 union select name,password from table2 注:union前后两个s. 阅读全文
posted @ 2012-02-21 21:10 colyn 阅读(417) 评论(0) 推荐(0)
摘要:inner join,full outer join,left join,right jion内部连接 inner join 两表都满足的组合full outer 全连 两表相同的组合在一起,A表有,B表没有的数据(显示为null),同样B表有A表没有的显示为(null)A表 left join B表 左连,以A表为基础,A表的全部数据,B表有的组合。没有的为nullA表 right join B表 右连,以B表为基础,B表的全部数据,A表的有的组合。没有的为null查询分析器中执行:--建表table1,table2:create table table1(id int,name varch 阅读全文
posted @ 2011-12-19 17:13 colyn 阅读(188) 评论(0) 推荐(0)