Fixed error in one of the mysql queries