Reputation: 431
I am new to MySQL and want to pull/display a field that contains a space. I thought the following syntax would work - but it gives me an error code of 1054:
SELECT [Record ID] FROM testDB.all;
Upvotes: 0
Views: 28
Reputation: 18737
Try using backticks:
SELECT `Record ID` FROM testDB.all;
Side Note:
Back ticks are to be used for table and column identifiers, but are only necessary when the identifier is a MySQL reserved keyword, or when the identifier contains whitespace characters or characters beyond a limited set it is often recommended to avoid using reserved keywords as column or table identifiers when possible, avoiding the quoting issue.
Back ticks are necessary for situations like the following:
SELECT id, `my name`, `another field` , `field,with,comma`
Upvotes: 1