I have to write sql query with two different way, both are giving same output. But Still not understand
-
what is different between both query?
-
which one is fast in access?
-
which is more recommend?
Query # 1
SELECT PageControlDet.PageId, PageMaster.PageName, PageMaster.PageURL,
PageMaster.PageTitle, PageMaster.PageDescription
FROM AgentRoleAccessDet
INNER JOIN PageControlDet ON AgentRoleAccessDet.ControlId = PageControlDet.ControlId
INNER JOIN PageMaster ON PageControlDet.PageId = PageMaster.PageId
and
Query #2
SELECT PageControlDet.PageId, PageMaster.PageName, PageMaster.PageURL,
PageMaster.PageTitle, PageMaster.PageDescription
FROM AgentRoleAccessDet, PageControlDet, PageMaster
WHERE AgentRoleAccessDet.ControlId = PageControlDet.ControlId and
PageControlDet.PageId = PageMaster.PageId
ORDER BY PageControlDet.PageId
One uses
INNER JOIN, the other doesn’t. Just listing all of the tables in theFROMclause, separated by commas is an older style/syntax, that’s mostly deprecated these days. It’s from before theJOINsyntax was introduced into the standard.They should perform equally well. You’d have to generate execution plans to know for sure, but the optimizer should treat them both equally.
The first. Making the joins explicit and distinct from any filtering can help others to understand the query in the future. Also, as soon as you introduce
OUTERjoins, you’d need to use deprecated syntax to use the second style.