This question is about a clarification. I have a varchar-like table field in a MySql database which may contain single quotes in its value.
I need to perform some queries similar to:
select my_field
from my_table
where my_field = 'xxx'rrr';
Of course, the above does not work in MySql Workbench.
I have tried:
select my_field
from my_table
where my_field = 'xxx''rrr';
and
select my_field
from my_table
where my_field = 'xxx\'rrr';
They both seem to work from MySql Workbench.
However, these queries are crafted and executed in a PHP application. I would like to know whether there is a possible caveat or whether I can use any of the methods above? What is the right way to escape single quotes without using MySql functions?