MySQL is not sensitive to trailing spaces
73530589
Conclusion: It is recommended to trim the string in the query condition, preferably trim when the data is in storage.
Example1:
The field values in the table do not have spaces, where the query condition is with or without spaces.
Example: key= ' Test '
Query condition a:where key= ' test ', the query result is OK
Query condition b:where key= ' test ', query result is empty
Query condition c:where key= ' test ', the query result is OK
Conclusion: The Where query condition is sensitive to the space before the character, and the space after the character is ignored.
Example2: The field value in the table is preceded by a space, where query condition with or without spaces
Example: key= ' Test ' (4 spaces in front of test)
Query condition a:where key= ' test ', the query result is empty.
Query condition b:where key= ' test ' (4 spaces in front of test), query result OK.
Query condition c:where key= ' test ', the query result is empty.
Conclusion: If the value of the field in the table is preceded by a space, the query criteria must match exactly the preceding space.
Example3: Field values in the table are followed by spaces, where query conditions with or without spaces
Example: key= ' Test ' (4 spaces behind test)
Query condition a:where key= ' test ', query result OK
Query condition b:where key= ' test ' (4 spaces after test), query result OK
The query condition c:where key= ' test ' (with 4 spaces in front of test) and the query result is empty.
Conclusion: If the value of the field in the table is followed by a space, the query condition is the same as example1.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced. 73530589
MySQL is not sensitive to space after the query processing of the MySQL database