3

My simple WHERE query is not working. It says column "Exception" does not exist, but the column it type, that is only a value.

SQL Query:

select * from logs
where type = "Exception"

Picture of the error

  • 7
    `"` characters are for column names. You have to use `'` characters. – S-Man Jul 22 '19 at 07:33
  • 2
    @S-Man More generally, double quotes are for _identifiers_, which could include table and database names, in addition to column names. – Tim Biegeleisen Jul 22 '19 at 07:35
  • https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS –  Jul 22 '19 at 07:39
  • @LukaszDabrowski: you will need double quotes for your case sensitive column names however. You should really re-create that table **without** using any double quotes. As a rule of thumb: never use double quotes in SQL –  Jul 22 '19 at 07:39

2 Answers2

4

As S-Man commented the answer is: " characters are for column names. You have to use ' characters.

4

Try this one:

SELECT *
FROM
   logs
WHERE
   type = 'Exception'
dbz
  • 411
  • 7
  • 22