i have a postgres db here where i can get the data from like so:
SELECT * FROM berlinBuildingFootprints
it returns all data from that table. when i want to receive on single datapoint like this:
SELECT * FROM berlinBuildingFootprints WHERE id = 'DEBE00YYH600008C'
it does not return anything, even if i know that this is in the database!
waht is wrong here? is the query wrong?
thanks a lot for help!!
2
Answers
You’re using the wrong quotes.
'id' = 'DEBC...'
compares a literal text value of'id'
to your target, so you’re just comparing two different text constants. You probably wanted"id"='DEBC...'
to compare the column namedid
to the target.Double quotes are for identifiers, single quotes for constants/literals. Doc warns about this:
If it still doesn’t work with the right quotes, you can inspect the value a bit closer: demo
In the spirit of Mandy and Laurenz’s points, you could also try ..
… or …
Both queries allow for trailing whitespace. The former query also allows for leading whitespace. The latter query allows for any string that starts with the characters before the % sign.