Is there a SQL standard to escape a column name? If not what works for mysql and sqlite? does it also work for sqlserver?
A:
For MySQL, use ticks `.
For instance:
SELECT `column`, `column2`, FROM `table`
Kerry
2010-05-25 01:38:55
you can have spaces in column names with ms sql!?!
acidzombie24
2010-05-25 01:41:37
you can! I wouldn't, though.
JMP
2010-05-25 01:43:01
Yes, you can have spaces or reserved words as entity names in MSSQL. You just need to [ ] them.
BoltBait
2010-05-25 01:43:19
+3
A:
The SQL-99 standard specifies that double quote (") is used to delimit identifiers.
Oracle, PostgreSQL, MySQL, MSSQL and SQlite all support " as the identifier delimiter (though they don't all use " as the 'default' - for example, you have to be running MySQL in ANSI mode and SQL Server only supports it when QUOTED_IDENTIFIER
is ON
.)
Dean Harding
2010-05-25 01:49:17