Philip Hamoui Philip Hamoui - 5 months ago 40
SQL Question

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

Answer

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;