Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
345 views
in Technique[技术] by (71.8m points)

sql - Postgresql Column Not Found, But Shows in Describe

There have been similar posts, but none helped me solve my problem.

I am trying to do a simple select on a table, retrieving only one column. The column shows in the describe table, but when I try to select it I get a column not found error. I am using the command line interface.

Table:

 id                        | integer                  | not null default 
 amazon_payment_id         | integer                  | not null
 source                    | character varying(10)    | not null
 timestamp                 | timestamp with time zone | not null
 status                    | character varying(50)    | not null
 statusReason              | character varying(100)   | not null
 transactionId             | character varying(50)    | not null
 transactionDate           | timestamp with time zone | 
 transactionAmount         | numeric(6,2)             | 
 errorMessage              | character varying(100)   | not null

etc.

Select:

select `transactionAmount` from ... where ... group by transactionAmount;

Error:

ERROR:  column "transactionamount" does not exist
LINE 1: select `transactionAmount` from ... where...

Does anyone have any idea why I would receive this error?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Why do you use ` in column name?

You can use it without any quote characters, while with quote characters it may be case sensitive. Also such quote char is ", and not `

So use:

select "transactionAmount" 
from ... 
where ... 
group by "transactionAmount";

Read about identifiers at: http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...