ERROR: column “…” does not exist

PostgreSQL internally converts all column and table names to lowercase when executing the SQL query.

If the column or table name contains uppercase letters, we need to use double quotes to be able to reference them.

When we get the error message

ERROR: column “username” does not exist

select * from public.”AspNetUsers” where UserName = ‘… ^

HINT: Perhaps you meant to reference the column “AspNetUsers.UserName”. SQL state: 42703

The first line of the error message shows, that PostgreSQL internally converted UserName to username. To be able to reference the column, use double-quotes. If you reference the table name too, don’t copy the hint, make sure the table and column names are separate strings in double-quotes with a period between them.

select *  from public."AspNetUsers" where "AspNetUsers"."UserName" = 'MY_VALUE';

Join the Conversation

2 Comments

Leave a comment

Your email address will not be published. Required fields are marked *