I am trying to search a column in PostgreSQL that has values containing single quote characters.
Here’s the string I’d like to search and fail to do properly:
activities,'L','D'
I’ve tried using LIKE with both $$ and ” to escape the single quotes but im not able to properly write down the query.
Here is my where clause:
where 1=1 and table.column LIKE '%activities,''L'',''D''%'
thank you in advance
2
Answers
I want to thank everyone for their input! It turned out the issue was not withe the SQL code itself, but rather with the fact the text was not consistent within the text column itself.
You can use single quotes to escape the single quotes, as follows:
Yoy can find a working example here: https://www.db-fiddle.com/f/hHCyXADG7dPGgsdf6kVf9d/8