SQL uses single quotes for string literals. Your string "Mel's Hou Rest, Mel's Lad Rest"
has double quotes around it which makes Postgres interpret it as an quoted identifier. You can use two single quotes to include one in the string.
SELECT * FROM cust WHERE home_location = ANY(string_to_array("Mel's Hou Rest, Mel's Lad Rest", ','))
-- ERROR: column "Mel's Hou Rest, Mel's Lad Rest" does not exist
SELECT * FROM cust WHERE home_location = ANY(string_to_array('Mel''s Hou Rest, Mel''s Lad Rest', ','))
-- OK
Also note that string_to_array
does not remove whitespace around the delimiter which might not be what you expect.
For example:
-- With whitespace around the delimiter
=> SELECT string_to_array('foo, bar', ',')
string_to_array
-----------------
{foo," bar"}
=> select 'foo' = ANY(string_to_array('foo, bar', ','));
?column?
----------
t
=> select 'bar' = ANY(string_to_array('foo, bar', ','));
?column?
----------
f
-- Without extra whitespace
=> SELECT string_to_array('foo,bar', ',')
string_to_array
-----------------
{foo,bar}
=> select 'foo' = ANY(string_to_array('foo,bar', ','));
?column?
----------
t
=> select 'bar' = ANY(string_to_array('foo,bar', ','));
?column?
----------
t
This of course can be countered by normalising the input before using it in the query. In somes cases it might be feasible to strip the whitespace in the query with string_to_array(regexp_replace('foo, bar', '\s*,\s', ','), ',')
but I would not complicate the queries like that without a good reason.