select but distinct sensitive words

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
duk
Forum Contributor
Posts: 199
Joined: Wed May 19, 2004 8:45 am
Location: London

select but distinct sensitive words

Post by duk »

hy guys...

i need some help, what i need to know is if its possible, for exemple you got 100 records all with lower and upper case characters then the user inputs a information, you want to check if there is someone with that name already, but i want to check lower and uper case letters with mysql is possible ???

thanks in advance
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

You can use the LCASE() (or LOWER()) and UCASE() (or UPPER()) functions. Information can be found in the MySQL manual on String Functions.
printf
Forum Contributor
Posts: 173
Joined: Wed Jan 12, 2005 5:24 pm

Post by printf »

If the names have mixed case AbCdE, then you can use a regex! If you don't want to use the regex engine, then just cast the field you are matching to BINARY, then your match will be truly case sensitive.

Example...


Code: Select all

// will only match (Dart) within the field, no other combinations of (dart) will match

SELECT city FROM `usa` WHERE BINARY city LIKE '%Dart%';

// will only match (Dartmouth), no other combinations of (dartmouth), will match

SELECT city FROM `usa` WHERE BINARY city = 'Dartmouth';
pif
Post Reply