문제

Today I'm reported a confused problem by our QA that our app's log in feature ignores case condiersation, and by debuging backend code I found the following SQL scripts run with the same results(Our database has only one user with name of 'duno'):

SELECT * FROM T_USER WHERE username = 'duno';

and

SELECT * FROM T_USER WHERE username = 'DUNO';

Above 2 SQL scripts run with the same user record. I just get confused about that, what special settings to MySQL need I do? or other reasons?

Thanks in advance.

도움이 되었습니까?

해결책

By default mysql query is case-insensitive.

To make it case sensitive use BINARY Keyword

SELECT * FROM T_USER WHERE BINARY username = 'duno';


Or

Instead of using the = operator, you use LIKE operator

SELECT * FROM T_USER WHERE username LIKE 'duno';

다른 팁

By default MySQL does case insensitive search. You can either change your query or your table definition to make the searches case sensitive. Read more about it in MySQL documentation Case Sensitivity in String Searches.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top