Go Back   Cloud Computing > Support > MySQL Issues.
 

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 05-19-11, 05:08
BOD Member
 
Join Date: Nov 2010
Posts: 91
Default How to deal with case sensitive records in MySQL?

Hi

I am facing very unusual problem with mysql. I have two records in my table, one with “jeremy” and one with “Jeremy”, but when I fired query
Quote:
SELECT * FROM Namelist WHERE Name = “Jeremy”;
MySQL returns two records Jeremy, and jeremy to me, how to set these two records as a separate record?
Reply With Quote
  #2 (permalink)  
Old 05-19-11, 05:20
Rozanne's Avatar
BOD Member
 
Join Date: Nov 2010
Posts: 116
Default

In this case you need to use BINARY compare in the WHERE clause, which will force to match records on the binary collection.

You should try following query:

Quote:
SELECT Name FROM Namelist WHERE BINARY Name = “Jeremy”;
Also try to fix the data so it doesn't happen and even better fix the design or the application so it cannot happen again.
Reply With Quote
  #3 (permalink)  
Old 05-19-11, 06:16
Kristine Habeck's Avatar
BOD Member
 
Join Date: Nov 2010
Posts: 122
Default

Let me jump here with my concern issue. I use following statement to check user name and password of users:

Quote:
SELECT COUNT (*) AS num FROM 'tb1users' WHERE BINARY user_name = 'un' AND password = 'pw'
problem is, it considers both user_name and password case sensitive, and I want only password as a case sensitive, so how can I change the statement?
Reply With Quote
  #4 (permalink)  
Old 05-19-11, 06:32
Rozanne's Avatar
BOD Member
 
Join Date: Nov 2010
Posts: 116
Default

The BINARY operator converts a string to an array of bytes and compares the results byte by byte. This only requests to the variable preceding the BINARY reserved word. I don't understand why you want to convert it into BINARY when you can compare it at a string level?

I am not sure about this statement, but you can try:

Quote:
select user_name, password from tb1users where binary password = 'pw';
You will get the list of users who are using same password.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump


All times are GMT -6. The time now is 00:50.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
Copyright © 1999-2012, BODHost Ltd. All rights reserved.