Can someone help point out to me what is wrong with this no brainer WHERE clause? Can someone help point out to me what is wrong with this no brainer WHERE clause? postgresql postgresql

Can someone help point out to me what is wrong with this no brainer WHERE clause?


Try with single quotes '' if you are trying to match a string

SELECT login FROM accounts WHERE login = 'loginname';

Check the documentation

There is a second kind of identifier: the delimited identifier or quoted identifier. It is formed by enclosing an arbitrary sequence of characters in double-quotes ("). A delimited identifier is always an identifier, never a key word. So "select" could be used to refer to a column or table named "select", whereas an unquoted select would be taken as a key word and would therefore provoke a parse error when used where a table or column name is expected.


Double quotes (") are used to refer to object names, in a case sensitive way. In this case, "loginname" is interpreted as a column name, and the query fails, since there is no such column. In order to refer to a string literal, you should use single quotes ('):

SELECT login FROM accounts WHERE login = 'loginname';-- Here ---------------------------------^---------^


It seems that the " " are the problem if you believe the documentation. Single quotes are required for string values.