I've been pulling my hair out. I have a very simple postgre database, one specific table has a column named lName (uppercase N). Now I know with postgre I must quote lName since it contains an uppercase N.
I am trying to query the database with the following statement:
SELECT *
FROM employee
WHERE "lName" LIKE "Smith"
But I am receive this error:
Warning: pg_query() [function.pg-query]: Query failed: ERROR: column "Smith" does not exist in .....
What is the issue here? Why is it saying the column is "Smith"?
PostgreSQL column does not exist exception occurs when we have used column did not exist in the table or it will occur when the used column name has lower case name and we have used upper case in our query.
The NOT EXISTS is opposite to EXISTS . It means that if the subquery returns no row, the NOT EXISTS returns true. If the subquery returns one or more rows, the NOT EXISTS returns false.
The Postgres IF NOT EXISTS syntaxFirst, we specify the name of the table to which we want to add a column. We supply the IF NOT EXISTS option after the ADD COLUMN clause, and then we specify the name of the column and its data type.
I would guess:
SELECT * FROM employee WHERE "lName" LIKE 'Smith'
(note the different quotes; "foo"
is a quoted identifier; 'foo'
is a string literal)
Also, in most SQL dialects, a LIKE
without a wildcard is equivalent to =
; did you mean to include a wildcard?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With