I have seen one sql query, which is like,
SELECT B.SubscriptionID
FROM
tblA A1
inner JOIN tblA A2 ON A1.AcctServiceID = A2.AcctServiceID
INNER JOIN tblB B ON A2.ServiceID = B.ServiceID
INNER JOIN tblC C ON B.SubscriptionID = C.SubscriptionID
WHERE
A1.ServiceID = 1302
AND (C.Type LIKE '%O%' OR C.Type LIKE '%A%')
Can any one explain what is the use of
tblA A1
inner JOIN tblA A2 ON A1.AcctServiceID = A2.AcctServiceID
and can we optimize above query? Please sugget me how to optimize the above query.
Please help me…
Thanks.
This line means you join tblA as A1 with the tblA as A2, and show line when AcctServiceID from tblA as A1 is the same as AcctServiceID from tblA as A2..
The way to optimize this query is remove this line, becouse don’t do anything. AcctServiceID aways be the same as AcctSerivceID becouse is the same field.