sql语句执行效率
1.
-- 声明变量
Declare @PlaneTemp Table (RecId int Identity(1,1), UserId int Not Null);
--从绑定数据中提取用户
Insert Into @PlaneTemp
Select Distinct UserId
From dbo.Coupon_MemberRelation
Where Remark like '%Plane% '
Select M.T_ID as 用户ID, M.UserName as 用户名, M.Mobile_NO as 手机号, M.Email
From dbo.CMS_Member As M, @PlaneTemp As T
Where M.T_ID = T.UserId
Order By M.T_ID ASC
Set NOCOUNT OFF
2.
Select a.T_ID as 用户ID, a.UserName as 用户名, a.Mobile_NO as 手机号, a.Email
From
CMS_Member AS a,
(
SELECT DISTINCT UserID
FROM Coupon_MemberRelation
WHERE Remark LIKE '%Plane% '
) AS b
Where a.T_ID = b.UserId
Order By a.T_ID ASC
请问各位,这两个sql语句,哪个执行效率更高一点,我不大会看
是不是临时表会消耗大一点啊,谁能给讲讲语句的效率啊,谢谢各位了
[解决办法]
第二个
[解决办法]
看数据量,要是数据量很大的话,索引条件很好的前提下第一种更有优势