3

I am doing a select * on a postgresql table, and everything looks good. But if I do:

SELECT Name from People

It says:

ERROR: column People.Name does not exist
SQL state: 42703
Character: 8

But the name column shows up during select *. I've tried:

SELECT People.Name from People

as well, with the same result. Am I missing something? It should be pretty easy to do this in any other database.

3 Answers 3

2

Try putting quotation marks around the column name, i.e. "Name"

Sign up to request clarification or add additional context in comments.

3 Comments

Workes, but I can't see why I can't just use the regular name without quotes.
probably because Name is a reserve word.
And also for the reason explained by George (lowercasing).
2

PostgreSQL converts everything to lowercase.

If you asks for this:

CREATE TABLE People
{
id SERIAL,
Att1 varchar(100)
-- constraints
};

SELECT Name FROM People;

You should get all the information, because pgsql converts this to

CREATE TABLE people
{
id SERIAL,
att1 varchar(100),
-- constraints
};

SELECT name FROM people;

If you built your table with pgAdmin and created field with mixed casing, you will need to quote them to be sucessfull, like this:

SELECT "Att1" FROM people

Comments

1

Name is a keyword, so it might not be handled well in this case. The best thing to do would be to alias the table like this:

SELECT Name from Peoplep

and then use the p to select the column:

SELECTp.Namefrom People p

1 Comment

Sorry I used Name as an example, my real field is not a keyname. I suspect it's a casing issue, but I used the same case shown in the GUI.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.