开发者

Where binary in SQL

开发者 https://www.devze.com 2022-12-23 09:38 出处:网络
I have an SQL statement: SELECT * FROM customers WHERE BINARY login=\'xxx\' A开发者_JS百科ND password=\'yyyy\'

I have an SQL statement:

SELECT * FROM customers WHERE BINARY login='xxx' A开发者_JS百科ND password='yyyy'

There are no blob/binary fields in the table, do I need the BINARY after the WHERE what else does it do?


BINARY is a built-in keyword that after your WHERE clause that forces a comparison for an exact case-sensitive match.

As a side note, you can also make columns case-sensitive by adding the BINARY keyword when you create your table.


https://dev.mysql.com/doc/refman/8.0/en/cast-functions.html#operator_binary

The BINARY operator casts the string following it to a binary string. This is an easy way to force a comparison to be done byte by byte rather than character by character. BINARY also causes trailing spaces to be significant.


SELECT 'user' = 'UsEr' // true
SELECT BINARY 'user' = 'UsEr' // false
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号