Precautions for using special characters in mysql 1. Directly spell it into SQL: www.2cto.com ● if it is "= ", the code for converting the escape character to '\ To \ is as follows: SQL = SQL. replace ("'", "'' "); SQL = SQL. replace ("\", "\"); ● if it is "like ", escape characters from '\ % _' to ''\ To \ (note that 8 characters are required, Chinese characters) the code for converting % to \ % _ is as follows: SQL = SQL. replace ("'", "'' "); SQL = SQL. replace ("\", "\"); SQL = SQL. replace ("%", "\ %"); SQL = SQL. replace ("_","\\_"); 2. SQL preprocessing ● only when "like" is used, escape \ To \ % to \ % _ to \ _ SQL = SQL. rep Explain ("\", "\"); SQL = SQL. replace ("%", "\ %"); SQL = SQL. replace ("_", "\ _"); Note: because MySQL uses the C implicit method (for example, "\ n") in the string "), you must repeat any "\" in your LIKE string. For example, in order to find "\ n", specify it as "\ n", in order to find "\", specify it as "\\\\" (The backslash is stripped once during java syntax analysis, and the other is when the Database pattern matching is completed, the reverse skew of a single line is matched ).