Fixed SQL syntax errors