For example:
select * from tablename where fields like "%string "hi" %";
Error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'hi" "' at line 1
How do I build this query?
For strings like that, for me the most comfortable way to do it is doubling the ' or ", as explained in the MySQL manual:
It is from http://dev.mysql.com/doc/refman/5.0/en/string-literals.html.
If you're using a variable when searching in a string,
mysql_real_escape_string()
is good for you. Just my suggestion: