How mysql queries are case sensitive
This article mainly introduces how mysql query is case-sensitive, which is very detailed and has certain reference value. Friends who are interested must finish reading it!
In mysql, you can use select query statements with binary keywords for case sensitivity, select statements for querying data, and binary keywords for case sensitivity, with the syntax "select * from table name WHERE binary field = field value".
The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.
How mysql queries are case sensitive
Queries are case-sensitive by default in mysql, but not case-sensitive by default in mysql.
Solution:
Mysql can add binary to the SQL statement to be case-sensitive. BINARY is not a function, it is a type conversion operator, and it is used to force the string after it to be a binary string, which can be understood to be case-sensitive when comparing strings.
1. Add binary to the query statement
Select * from users WHERE binary user_name = 'Zhang San' AND status! = 0
Second, add binary when building the table
Create table t {code varchar (10) binary} ALTER TABLE t_order CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin
After executing the sql above, the query on the table is case-sensitive.
The above is all the contents of the article "how mysql queries are case-sensitive". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!