Well, i have on my database, a field call int, and i made a program on C# thats update 'int' and some other fields, all went good till the int field says error in syntax. and i want SQL to mean int as just a name of a field and not a keyword. Thanks you very much.
-
Please post the SQL that's generating an error. – James Hill Aug 15 '11 at 18:46
-
8Tip: don't use keywords as identifiers - life's much easier that way! If you can't change it, surround identifier in square brackets for SQL Server, back ticks for MySQL, double quotes for Oracle... – Tim Lloyd Aug 15 '11 at 18:47
-
2Can you tag the question with your database provider. – ChaosPandion Aug 15 '11 at 18:56
1 Answers
INT
is a reserved word. You can use reserved words in MySQL by enclosing them in back-ticks:
SELECT `int` FROM mytable ...
But it's honestly easier if you refrain from using reserved words as identifiers. That is, name your column something else when you define the table.
It's also recommended to name columns something that more clearly describes their content or purpose. int
is pretty over-generic and so it can be confusing; it's like naming a C# function thefunction()
. :-)
See http://dev.mysql.com/doc/mysqld-version-reference/en/mysqld-version-reference-reservedwords.html for lists of reserved words by version of MySQL.
Re your comment:
Be careful to use the correct type of quote symbols. Use single-quotes to delimit string and date literals. In MySQL, use back-ticks to delimit identifiers for columns, tables, etc.
SELECT ... WHERE `column` = 'string'
On a US keyboard, the back-ticks are on the same key with the tilde (~).
I apologize for assuming that you're using MySQL. You might be using Microsoft SQL Server or some other brand of RDBMS. Microsoft SQL Server doesn't use back-ticks; instead you need to enclose identifiers in square brackets.

- 1
- 1

- 538,548
- 86
- 673
- 828
-
Thank you very much guys , but its still not working , thats the code im trying to exceute : update characters SET 'int' = '5' WHERE name= 'myname' and im still get :You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''int' = '5' WHERE name= 'myname'' at line 1 Thanks guys, – user895450 Aug 15 '11 at 18:50