7

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.

Mohammed Yasin
  • 487
  • 7
  • 12
  • 1
    Apart from the case-sensitivity problem: String constants need to be put in single quotes in SQL, double quotes are for identifiers. `"xxx"` refers to a column named `xxx` but `'xxx'` is a string literal –  May 16 '17 at 07:45

1 Answers1

22

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';
mohammad
  • 2,232
  • 1
  • 18
  • 38