Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgres - spaces and special characters in column name - how to select these in query

Tags:

sql

postgresql

I have table in postgres test1 and columns "Username","# of Applications", "# of R Applications" .

when tried to query these using select query i get error-

select Username, "# of Applications","# of R Applications" from public.test1 

Error ERROR: column "username" does not exist LINE 1: select Username, "# of Applications" from public.test1...

Similarly for all other 2 columns as well....

how do i select these columns in select query?

like image 963
Geeme Avatar asked Oct 21 '25 11:10

Geeme


1 Answers

Username is unquoted, so becomes username which the error suggests.

If your table has a column named Username, this should work

select "Username", "# of Applications","# of R Applications" from public.test1 
like image 191
theRemix Avatar answered Oct 24 '25 05:10

theRemix



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!