Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres - Escaping a Question Mark (?) in a column name

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!

like image 458
user2490003 Avatar asked Sep 10 '25 19:09

user2490003


1 Answers

use double quote:

 select "confirmed?" from user_purchases;

DEMO

like image 72
Juan Carlos Oropeza Avatar answered Sep 13 '25 08:09

Juan Carlos Oropeza