3

I am trying to run a basic select Query in PostgreSQL, but I am having trouble using the column alias. I tried to create the alias as randomfield As [Space In Name] but it gave an error of

Error: syntax error at or near "["
Line 2: randomfield As [Space In Name]

And I also tried to do the alias w/o the brackets but that presented an error as well. How do you alias with a space in Postgresql?

Select randomfield As [Space In Name]
From saledata
Neil McGuigan
  • 8,423
  • 4
  • 39
  • 56
  • https://www.postgresql.org/docs/current/static/sql-syntax-lexical.html#sql-syntax-identifiers –  Oct 27 '17 at 05:48

1 Answers1

5

Identifiers with special characters require double quotes in SQL:

SELECT randomfield AS "Space in Name" FROM saledata
Jonathan Fite
  • 8,666
  • 1
  • 23
  • 30