4

One of the columns in a Postgres DB I inherited has a question mark in the name.

When I try to select it, it throws an error

> select confirmed? from user_purchases;

ERROR:  column "confirmed" does not exist
LINE 1: select confirmed? from user_purchases;
               ^
HINT:  Perhaps you meant to reference the column "user_purchases.confirmed?".

I've also tried selecting it with backticks (`confirmed?`) and quotes ("confirmed?") but the same error is raised.

How do I select this field?

Thanks!

user2490003
  • 10,706
  • 17
  • 79
  • 155

1 Answers1

5

use double quote:

 select "confirmed?" from user_purchases;

DEMO

Juan Carlos Oropeza
  • 47,252
  • 12
  • 78
  • 118
  • Thanks! So I had tried this and it didn't work, but I just realized that I was using a table alias, which I hadn't made clear in the original question. So for anyone else in the same situation using table aliases, it's `select up."confirmed?" from user_purchases up`. – user2490003 Feb 02 '18 at 18:58