Regexp in MySQL?! I'm in!
First of all, I'll quote something, from this page:
In MySQL, SQL patterns are case-insensitive by default.
If you really want to force a REGEXP comparison to be case sensitive, use the BINARY keyword to make one of the strings a binary string.
This meaning that it makes no sense to query using e regex like this:
SELECT * FROM `users` WHERE `Username` REGEXP '^[A-Za-z]{15}$'
It's still going to find you names containing upper- AND lower-case characters. The above pattern works exactly like this one:
SELECT * FROM `users` WHERE `Username` REGEXP '^[a-z]{15}$'
Yups. This too will find you names which contain some (or none, or all) upper-case letters.
"So how do you match case-sensitive style?", I hear so asking. You've guessed it: REGEXP BINARY.
SELECT * FROM `users` WHERE `Username` REGEXP BINARY '^[A-Z]{15}$'
The above query matches any 15-character long names that are all - and, by God , I mean ALL - uppercase.
PS: Thx, btw. I've learned something today. Didn't know all that stuff I've just wrote you. :rolleyes: I just hope I'm right.
PPS: The back ticks (`) in the query it's just me being precautious.