Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I query in psql. If column name like camelCase [duplicate]

Tags:

postgresql

My psql table structure like below:

id userName gender  
1   xxxx     Male

if I am using query like below from psql shell:

select * from table where userName="xxx";

It gives error: Error: column "userName" does not exists.

How can I query if column name contain with camelCase.

like image 387
Mohammed Yasin Avatar asked Dec 11 '22 11:12

Mohammed Yasin


1 Answers

All identifiers are converted to lower case in postgres. To use upper case identifiers you should use double quotes around identifier to say postgres to not convert it to lower case :

select * from table where "userName" = 'xxx';
like image 136
mohammad Avatar answered May 18 '23 00:05

mohammad