How Do You Solve This SQL Problem When You Receive the Message “ERROR: Syntax Error at or Near”?

Problem scenario
You are trying to update a SQL table with a SQL statement (using the "UPDATE" keyword).  You keep getting "ERROR:  syntax error at or near" with a reference of the value you are trying to give to a cell in a row in a SQL table.  You verified you have no extra commas, apostrophes, or semicolons in your SQL UPDATE statement.  You verified that the columns exist in the table and are spelled correctly in your UPDATE statement. What do you do to have your UPDATE statement work?

Verify your WHERE clause is correct.  If your WHERE clause is looking for a value (e.g., where name = 'jones') in the table that matches 0 rows, then you may get this problem "ERROR:  syntax error at or near."  Once your WHERE clause matches the value of one or more rows, the UPDATE SQL statement should work.

Leave a comment

Your email address will not be published. Required fields are marked *