One of the column names in my database is two words long, including a blank space, i.e.: Area One
. I am using SELECT and referring to the column names to pull the data I want. Now if I name the column _Area_One_
, my SELECT works, but if I use _Area One_
, it does not. It says Unknown column 'Area' in 'field list'
Ideas?
Column names can contain any valid characters (for example, spaces). If column names contain any characters except letters, numbers, and underscores, the name must be delimited by enclosing it in back quotes (`).
SQL Server TRIM() Function The TRIM() function removes the space character OR other specified characters from the start or end of a string. By default, the TRIM() function removes leading and trailing spaces from a string. Note: Also look at the LTRIM() and RTRIM() functions.
You use NULL : insert into table tablename values (12, 13, 19, NULL, NULL, NULL, NULL, 1, NULL, 2, NULL, 5); You can also use '' if the column is a string and by "blank" you mean "empty string".
Rule 2g (Special Characters) – Field names should contain only letters and numbers. No special characters, underscores or spaces should be used. Indexes will remain named as the SQL Server default, unless the index created is for a special purpose.
Use backticks.
SELECT * FROM `Area One`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With