Fixed missing space in sql queries