Reputation: 251
How do you select a column of a specific table when you escape the names with quotes? The following doesn't work:
SELECT "UnitTest1.Name" FROM "UnitTest1" WHERE "Name" = 'One';
It works if I remove the table name from the selected column, but that's not what I want because I plan to include a second table later which might share a column name or two.
The error I'm getting:
ERROR: column "UnitTest1.Name" does not exist LINE 1: SELECT "UnitTest1.Name" FROM "UnitTest1" WHERE "Name" = 'One... ^
********** Error **********
ERROR: column "UnitTest1.Name" does not exist SQL state: 42703 Character: 8
Upvotes: 2
Views: 61
Reputation: 8497
Wrap in separate double quotes for both tablename and columnname, this should work fine
SELECT "UnitTest1"."Name" FROM "UnitTest1" WHERE "Name" = 'One';
Upvotes: 3
Reputation: 311308
The quotes protect an identifier from being parsed, so the query fails, since you don't have a column called "UnitTest1.Name"
. These are two identifiers (a table name and a column name), which need to be quoted separately:
SELECT "UnitTest1"."Name" FROM "UnitTest1" WHERE "Name" = 'One';
Upvotes: 5