首页 > 数据库技术 > 详细

sql语句学习

时间:2014-06-23 06:30:05      阅读:411      评论:0      收藏:0      [点我收藏+]

select top 1 id from AddWorkFlow order by id desc
返回查询结果中前几条数据

select count(1) as total from Base_Users where DeptId=‘101010102‘ and iDel=0
返回查询的记录个数

select max(UserId) as total from Base_Users where DeptId=‘101010102‘ and iDel=0
返回查询内容的最大值或最大长度


select m.ModuleCode as cModuleCode,LEN(m.ModuleCode) AS [Length],m.ModuleName as cModuleName
,‘00000000000‘ AS cPower FROM Menu AS m ORDER BY CAST(m.ModuleCode AS INT)
CAST表示将里面的内容转化为对应的数据类型


JOIN 分为内连接,外连接(左外连接,右外连接,全外连接)

内连接: SELECT A.* FROM A INNER JOIN B ON A.ID=B.ID
SELECT a.cCardNo, a.cDoorId, a.cTimeId, b.vEmp_name, b.vDepart, b.dEndDate
FROM MJ_MacPower AS a INNER JOIN
Employee AS b ON a.cCardNo = b.vCardNo


左外连接: SELECT A.* FROM A LEFT JOIN B ON A.ID = B.ID

右外连接: SELECT A.* FROM A RIGHT JOIN B ON A.ID = B.ID

全外连接: SELECT A.*, B.* FROM A FULL OUTER搜索 JOIN B ON A.ID = B.ID

sql语句学习,布布扣,bubuko.com

sql语句学习

原文:http://www.cnblogs.com/wxs2008/p/3799621.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!