I have the following value in my table:
When I Don\’t Know What To Do
Notice the apostrophe is already escaped. Now I want to select this value from this table using the following SQL string:
SELECT * FROM wp_wpsc_productmeta WHERE meta_value = ‘When I Don\’t Know What To Do’
I am getting 0 rows returned. When I change the SQL string to this:
SELECT * FROM wp_wpsc_productmeta WHERE meta_value LIKE ‘When I Don%’
I get my result set correctly. So, my question is, how do I write the SQL string so that I can select a value from a table when that value has an already-escaped apostrophe in it?
Please do not answer that I should use parameters. I’d very much like to figure out the answer using the method that I’m trying. Thanks for your help!
What language are you using? I think the language is probably interpreting the escape backslash as an escape for its benefit, so you may need to do it twice to ensure the database sees it too: