fixed syntax errors in sql