[thelist] LEFT JOIN and INNER JOIN

Jon Molesa rjmolesa at consoltec.net
Wed Apr 4 15:13:08 CDT 2007

I saw some interesting discussion on here earlier in reference to some
joins.  I hope to catch up on that tonight when I get home.

My question is:  Can you you have....

Well scape that MySQL just responded to me.

Now the question is:  Is there a way to optimize a LEFT JOIN INNER JOIN


, calls.location
, calls.region
, agents.agentid
, agents.agentname
FROM calls
LEFT JOIN (agents
    INNER JOIN agentcommissions
    ON agents.agentid=agentcommissions.agent_id)
ON calls.groupid=agents.groupid
WHERE (calls.CommssionCycle BETWEEN 20071201 AND 20071205)
GROUP BY calls.id, calls.region;

When I ad the INNER JOIN it triples the run time of the query and
returns only the first record of the agents table as the value
in agents.agentid and agents.agentname.  It is very strange.  Perhaps
someone could explain the order of operations to me?  Any insight is

Jon Molesa
rjmolesa at consoltec.net

More information about the thelist mailing list