Fix duplicate tablename alias in mysql query.

This is the fix that Jason and I discussed over email.