Use inner join instead of a left join.

In some database servers an INNER join performs better than a LEFT join.

Fixes #3979