Most of my order queries are based on the first SQL statement, and the query order results are unique. However, there are two query results in this order. why? Under normal circumstances, the field attribute is a string. is the value the same without quotation marks? Please...
Most of my order queries are based on the first SQL statement, and the query order results are unique. However, there are two query results in this order. why? Under normal circumstances, the field attribute is a string. is the value the same without quotation marks? Please advise
Query results using the first SQL statement
Reply content:
Most of my order queries are based on the first SQL statement, and the query order results are unique. However, there are two query results in this order. why? Under normal circumstances, the field attribute is a string. is the value the same without quotation marks? Please advise
Query results using the first SQL statement
Of course, it is different. mysql will perform implicit type conversion. when comparing numbers and varchar, mysql will convert varchar to numbers. if the password type is a string, if the query condition is int 0, it will match.show warnings;View
I'm also curious to post your query results.
How many bits does your varchar have? is it automatically ignored because it is not long enough?
Out_trade_no, are all numeric characters, right? It may be that the value is too large. When implicit type conversion is performed, a part of the data is intercepted, resulting in a match. this reminds you of precautions for writing SQL statements, the string data type should be enclosed in quotation marks to avoid unnecessary vulnerabilities.
Varchar to numeric truncation.
Without quotation marks, mysql scans the entire table first, and converts the queried results into numbers using varchar.
If the single quotation mark type is matched, index scanning is used directly (if the column has an index ).
Therefore, without quotation marks, performance problems may occur.