MySQL JOIN bug-fix for multiple FROM tables