0

I want to select a count of all surveys where the survey.property.address.city == "Garrison". I have the following tables (stripped for your convenience):

surveys                 properties             addresses     
----------------        ---------------        ---------
id | property_id        id | address_id        id | city

And the failing query:

SELECT count(*)
FROM   surveys s
JOIN   properties p ON s.property_id = p.id
JOIN   addresses a ON p.address_id = a.id
WHERE  a.city = "Garrison"

The error message as follows:

ERROR:  column "Garrison" does not exist
LINE 5: WHERE addresses.city = "Garrison";
2

Use single quotes instead of double:

SELECT count(*)
FROM   surveys s
JOIN   properties p ON s.property_id = p.id
JOIN   addresses a ON p.address_id = a.id
WHERE  a.city = 'Garrison'

Not the answer you're looking for? Browse other questions tagged or ask your own question.