How did it know it was the same?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
xterra
Forum Commoner
Posts: 69
Joined: Mon Mar 06, 2006 12:52 pm

How did it know it was the same?

Post by xterra »

I realized earlier that a code bug would allow two different users "test" and "Test" to exist at one time, so I needed to fix that. However, to my surprise, when I woke up earlier to test my flaw, it worked flawlessy. In other words, somehow my query knew that "test" and "Test" were infact the same, and it would not allow the user to register "test". So that's actually good.


But I'd like to know why did it know? I figured it was because I used LIKE. So, testing my theory I replaced LIKE with "=". I assumed that = checks for exactly case, and LIKE disregards case. But no, still! No matter what keyword I use, whether I use LIKE or = , it knows that TEST and test are infact the same.


Can someone explain this to me? Or did I just confuse everyone?


Thanks in advance.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

show your exact queries
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The fields are strings, but not binary. MySQL will allow case variance in non-binary fields. What variances are allowed, I believe is controlled by the collation used on the tables.
xterra
Forum Commoner
Posts: 69
Joined: Mon Mar 06, 2006 12:52 pm

Post by xterra »

That would make sense because it also allowed me to do < > and = comparisons.

Thanks.
Post Reply