Explain in detail the problem that the string can be matched with spaces at the end of the string in Mysql query conditions.
I. Table structure
TABLE person
Idname1 you 2 you (one space) 3 you (two spaces)
II. Query and result
Select * from person where `name` =?
No matter? = "you + several spaces" will retrieve all three results.
Third, the reason
MySQL proofreading rules belong to PADSPACE and trailing spaces are ignored.
It's for varchar char text. The data type of the text class
This is the SQL standardization behavior. There is no need to set and cannot be changed.
Fourth, what if you want to make an accurate query?
Method 1: like
Select * from person where `name` like?
Method 2: BINARY
Select * from person where `name` = BINARY?
BINARY is not a function, but a type conversion operator. It is used to force the string after it to be a binary string, which can be understood as an exact match.
The above are all the relevant knowledge points of this introduction, if you have anything to add, you can contact the editor.