ERROR: column “…” does not exist

PostgreSQL converts all column and table names to lowercase in 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

This error message shows, that PostgreSQL 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';

Leave a comment

Leave a Reply