single double quotes in MySQL use
MySQL uses the basic DML type of the SQL statement, "" and "is the default string label symbols. However, in the actual situation, the following situation often occurs:
One: Query situation
Select book_id from PD WHERE isbn= ' 9787542739810 ' and book_name= ' "dispel the charm" and "return to the charm";
In this case, the book_name corresponding string is not a problem, and the SQL statement does not have a syntax problem. But look at the following statement:
SQL, insert into yourtable (F1,F2) VALUES (+, ' abc ')
SELECT book_id from PD WHERE isbn= ' 9787542739810 ' and book_name= ' let's go! Ma Xiaoboro ';
Report exception: You have a error in your SQL syntax;
In this, you may say, you put the "let's go! Ma Xiaoboro" in the periphery of the two single quotation marks in double quotes do not do it. But the reality is that Murphy's law is the worst-case scenario. In many cases, we do not know the incoming, delete, change, check the string, whether it contains "," or both, so it is not easy to encounter single quotation marks replaced by double quotation marks, double quotation marks are replaced by single quotation marks. This will require the use of the SQL escape character .
Two: Insert Condition
string data is enclosed in single quotation marks, if the inserted data contains single quotation marks, you need to deal with, you can replace single quotation marks with two single quotation marks, in SQL, two consecutive single quotes represent a single quote character, for example
Insert into yourtable (F1,F2) VALUES (+, ' ab ' ' C ') indicate insert
New record F2 field AB ' C
Use the function replace to achieve this function: replace (YOURSTR, "'", "" ")
The problem of stitching single and double quotes in SQL statements