给5分,探讨下这两条SQL语句的效率高低!!
1、SELECT A.*,B.OrganName,C.PositionName FROM HR_Employee A
LEFT JOIN HR_EmpOrgan B ON A.EmpID=B.EmpID
LEFT JOIN HR_EmpPosition C ON A.EmpID=C.EmpID
2、SELECT A.*,
(SELECT OrganName FROM HR_EmpOrgan WHERE EmpID=A.EmpID) AS OrganName ,
(SELECT PositionName FROM HR_EmpPosition WHERE EmpID=A.EmpID) AS PositionName
FROM HR_Employee A
这两条SQL语句的效率高!! 并说明!!
谢谢!!
------解决方案--------------------1 高
------解决方案--------------------自己 Ctrl + L 下不就知道了
------解决方案--------------------实际做一次,用事件探查器监控
------解决方案--------------------子查询会慢
------解决方案--------------------单两句话很难判断,我觉1会高