区分大小写的数据库查询 [英] Case Sensitive Database Query

查看:237
本文介绍了区分大小写的数据库查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
mysql区分大小写的查询

Possible Duplicate:
mysql case sensitive query

正在处理一个PHP脚本,该脚本检查数据库中某些值.到目前为止,我认为它工作正常,但是我发现了一个问题.

'm working on an PHP script that checks some values to the ones in the database. So far I thought it worked right, but I found an problem.

查询未在查找特定字符.

The query isn't looking for the specific characters.

因此,如果我使用此查询:

So if I use this query:

SELECT *
FROM `facilitydb_login`
WHERE
facilitydb_login.`password` = 'PASS'

我想要结果,因为密码是PASS.但是,如果您填写通行证(小写),则会返回相同的条目.

I want the result, because the password is PASS. But if you fill in pass (lowercase) the same entry is returned.

如何区分大小写?

推荐答案

您应使用区分大小写的排序规则,例如

you should use case sensitive collation, for example

SELECT *
FROM `facilitydb_login`
WHERE facilitydb_login.`password` collate latin1_general_cs = 'PASS'

名称中的CS表示区分大小写

CS in the name means that it's Case Sensitive

这篇关于区分大小写的数据库查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆