我想加入Account
ANDSales
表。
表的主键Account
:id,YearCode,AgentId
哪个查询运行得更快
查询 #1:
SELECT *
FROM account A
JOIN sales s on a.id = s.id
AND a.yearcode = s.yearcode
AND a.agentid = s.agentid
WHERE a.yearcode = 1
AND a.agentid=56
AND a.id=976
查询 #2:
SELECT *
FROM Account A
JOIN sales s on a.id=s.id
WHERE s.yearcode=1
AND s.agentid=56
AND a.yearcode=1
AND a.agentid=56
AND a.id=976
查询 #3:
SELECT *
FROM account a, sales s
WHERE a.id=s.id
AND a.yearcode=s.yearcode
AND a.agentid=s.agentid
AND a.agentid=56
AND a.yearcode=1
AND a.id=976