So I have what seems to be a really weird problem.

I have imported a table from QGIS into a postgresql + postgis database. I simply want to select a few columns from that, but I can't. enter image description here

whats funny is that i can use the select query for the lowercase fields and it works, but not for the uppercase ones, such as LABELRANK. the error shows that such a column does not exist.

why is that so?

closed as unclear what you're asking by MDCCL, hot2use, LowlyDBA, Md Haidar Ali Khan, Tom V Oct 9 '18 at 7:51

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Welcome to DBA.SE. We appreciate your participation. However, the community does expect a certain quality in the questions posted. Consider reading the article: How do I ask a good question?. Currently your questiond doesn't contain enough information and might be closed as unclear what you're asking. For example; Why don't you just show us your simple SELECT statement in your question, so that we can determine that you don't have a "simple" syntax error? – hot2use Oct 8 '18 at 18:38

Probably this columns names has been created using double-quotes.

You should use double-quotes in your SELECT statement.

create table tbl (field1 int, "FIELD2" int, field3 int);
insert into tbl values (1,2,3),(4,5,6);
select field1, field2, field3 from tbl;
ERROR:  column "field2" does not exist
LINE 1: select field1, field2, field3 from tbl;
HINT:  Perhaps you meant to reference the column "tbl.field1" or the column "tbl.field3".

select field1, "FIELD2", field3 from tbl;
field1 | FIELD2 | field3
-----: | -----: | -----:
     1 |      2 |      3
     4 |      5 |      6

db<>fiddle here

  • yes thank you. I didn't realize that sql doesn't recognize capital letters like this – Dhaval Shukla Oct 10 '18 at 10:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.