select top 1 id from
返回查询结果中前几条数据select count(1) as total
返回查询的记录个数select max(UserId) as total from
返回查询内容的最大值或最大长度select LEN(m.ModuleCode) AS [Length],'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.dEndDateFROM 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