JackTurky JackTurky - 6 months ago 11
SQL Question

How to get correct query in sql when field of coloumn has apex inside

i'm trying to do this query:

SELECT *
FROM TABLE
WHERE value1='THIS'S AN EXAMPLE'.


The problem is that apex inside content will give error on query. how can i solve it? can someone help me?

Answer

Try escaping it like that:

SELECT * 
FROM TABLE
WHERE value1='THIS''S AN EXAMPLE'

where '' is 2 single quotes.

But best would be to make this a parametrized query. If you're running it from your code.