View Full Version : Detecting CAPs in fields with SQL
tom.fogarty
05-12-2008, 04:52 PM
Hi
I'm new to using SQL and wondered if there is a standard command/method using SQL to test if the characters in a field are capitalised.
Or is this an impossible thing to achieve?
Thank you
Tom
Fumigator
05-12-2008, 05:29 PM
I reckon you could use a regular expression (http://dev.mysql.com/doc/refman/5.0/en/regexp.html) to test for upper/lower case...
tom.fogarty
05-12-2008, 05:41 PM
Hi
Thank you - I didn't realise there was an 'UPPER' expression!
Tom
tom.fogarty
05-12-2008, 06:04 PM
Hi
Actually I'm having difficulty with the syntax now:
I've tried:
WHERE a.name =(UPPER(name))
Which compiles, but doesn't return the results I want - and I'm not sure what I'm doing wrong?
An advice would be much appreciated
Thanks!
Tom
abduraooft
05-12-2008, 06:10 PM
Have a try by adding BINARY keyword like
WHERE BINARY a.name =(UPPER(name))
tom.fogarty
05-12-2008, 06:15 PM
Many thanks - it's working perfectly now!
Much obliged
Tom
Fumigator
05-12-2008, 06:55 PM
At first I couldn't see why BINARY would solve your problem but I looked it up and found that BINARY right-trims spaces so that's probably what's going on.
vBulletin® v3.8.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.