philippos
philippos

Reputation: 1293

SQL - HINT to reference a column

I am very beginner at SQL, so I am sorry if this question is primitive.
I just started following the tutorial of http://www.w3schools.com, so downloaded the "Northwind" database to try working on it, and using the pgAdmin 3 console to access the DB. I just tried simple command to choose one column of the table, but it gives the same following message with any column from any table

LINE 1: select City from Customers;
                        ^
HINT:  Perhaps you meant to reference the column "customers.City".

I would like to ask is there any thing wrong in my command? and how to fix it?

Thanks

Upvotes: 34

Views: 65265

Answers (3)

James L.
James L.

Reputation: 14515

My working query ended up looking like:

select descr from activity where "activity"."scheduleId"='6sdCkROlyMo';

Upvotes: 9

Tometzky
Tometzky

Reputation: 23890

When you imported this "Northwind" database column names were imported in CamelCase - your import must've added double quotes to column identifiers to create table queries.

This is rather unfortunate, as this would cause that you'd have to quote them also in all queries, like:

select "City" from customers;

To remain sane I'd suggest you to rename all columns to lower case. This way it wouldn't matter what case you use, as Postgres converts all unquoted identifiers to lower case automatically. Then any of this would work:

select city from customers;
select City from Customers;
SELECT CITY FROM CUSTOMERS;

Upvotes: 66

Robert Columbia
Robert Columbia

Reputation: 6418

There is nothing wrong with your query. It looks like your tutorial wants you to follow the practice of always prepending the table name to columns you reference. In reality, this is only required when it would otherwise cause an ambiguity (e.g. if you are referencing two tables, both of which have a City column).

Upvotes: 0

Related Questions