0

I have an sql table that looks like this in postgresql called test.

    date    |  data   |      source      
------------+---------+------------------
 2015-09-23 | 128     | aaamt
 2015-09-24 | 0       | aaamtx2
.....

I type SELECT * FROM test where source="aaamt" but I get the following error,

ERROR:  column "aaamt" does not exist
LINE 1: SELECT * FROM test where source = "aaamt";

Why am I getting this error and how to I fix it?

1

2 Answers 2

11

You need to use single quote instead of double quote

SELECT * FROM test where source = 'aaamt'
Sign up to request clarification or add additional context in comments.

Comments

1

Double quotes indicate to Postgres that you are trying to specify an identifier such as a column or table name. Use single quotes for string literals, and your query should work:

SELECT *
FROM test
WHERE source = 'aaamt';

To be clear here, you current query is basically being interpreted as this:

SELECT *
FROM test
WHERE source = aaamt;

Here aaamt is being treated as a column name or maybe some other database identifier, but not as a string literal.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.