Thread: ERROR: column 'xxx' does not exist (under v. 7.4.1)

ERROR: column 'xxx' does not exist (under v. 7.4.1)

From
Iker Arizmendi
Date:
Using psql and running as the owner of the table "app" I
try to access the columns of the table like so:

    SELECT * FROM app;

which returns all the columns in the table including
the one I'm interested in, which is "companyID".
If instead I use something like:

    SELECT companyID FROM app;

I get the following:

    ERROR: column "companyid" does not exist

even though the column DOES exist (the previous query
returned "companyID" as one of the column headers). Any
suggestions as to what I might be missing? I'm running
Postgres 7.4.1.

Regards,
Iker



Re: ERROR: column 'xxx' does not exist (under v. 7.4.1)

From
Mark Gibson
Date:
Iker Arizmendi wrote:

>
> Using psql and running as the owner of the table "app" I
> try to access the columns of the table like so:
>
>    SELECT * FROM app;
>
> which returns all the columns in the table including
> the one I'm interested in, which is "companyID".
> If instead I use something like:
>
>    SELECT companyID FROM app;
>
> I get the following:
>
>    ERROR: column "companyid" does not exist
>
> even though the column DOES exist (the previous query
> returned "companyID" as one of the column headers). Any
> suggestions as to what I might be missing? I'm running
> Postgres 7.4.1.
>
> Regards,
> Iker


You need to quote the table name if it contains upper case or strange
characters:

SELECT "companyID" FROM app;

--
Mark Gibson <gibsonm@cromwell.co.uk>
Web Developer & Database Admin
Cromwell Tools Ltd.
Leicester, England.



Re: ERROR: column 'xxx' does not exist (under v. 7.4.1)

From
Karsten Hilbert
Date:
> the one I'm interested in, which is "companyID".
                                      ^^^^^^^^^^^
>    SELECT companyID FROM app;
            ^^^^^^^^^
>    ERROR: column "companyid" does not exist
                   ^^^^^^^^^^^
Look closely at the capitalization and quoting.
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346

Re: ERROR: column 'xxx' does not exist (under v. 7.4.1)

From
Mark Gibson
Date:
Mark Gibson wrote:

>
> You need to quote the table name if it contains upper case or strange
> characters:
>
> SELECT "companyID" FROM app;
>
Obviously I meant column name, but it applies to any object identifier ;)

--
Mark Gibson <gibsonm@cromwell.co.uk>
Web Developer & Database Admin
Cromwell Tools Ltd.
Leicester, England.


Re: ERROR: column 'xxx' does not exist (under v. 7.4.1)

From
Joe Sunday
Date:
On Thu, Feb 05, 2004 at 10:00:21AM -0500, Iker Arizmendi wrote:

>
> Using psql and running as the owner of the table "app" I
> try to access the columns of the table like so:
>
>    SELECT * FROM app;
>
> which returns all the columns in the table including
> the one I'm interested in, which is "companyID".
> If instead I use something like:
>
>    SELECT companyID FROM app;
>
> I get the following:
>
>    ERROR: column "companyid" does not exist
>

SELECT "companyID" FROM app;

You've stored a case sensitive column name in the table, but
by default Postgres will fold all identifiers to lower case
unless quoted.

--Joe

--
Joe Sunday <sunday@csh.rit.edu>  http://www.csh.rit.edu/~sunday/
Computer Science House, Rochester Inst. Of Technology