If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Help finding Mixed case records

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-31-10, 04:09
andy982183 andy982183 is offline
Registered User
 
Join Date: Mar 2010
Posts: 18
Question Help finding Mixed case records

Hello,

I am newbie in MySql.

I require a query which can find mixed case records in a table

eg.
TABLE1
Abc Xyz (title case)
ABC XYZ (upper case)
abc xyz (lower case)
AbC Xyz (mixed case)
Abc XyZ (mixed case)

Output:

AbC Xyz (mixed case)
Abc XyZ (mixed case)

Any Help ?

Thanks
Reply With Quote
  #2 (permalink)  
Old 03-31-10, 04:19
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Quote:
Originally Posted by andy982183 View Post
Any Help ?

Usually MySQL is set up to ignore case. I believe what you need to use are regular expressions. I think something like this will do it for you:
Code:
select name from YourTable where name regexp '[A-Z][a-z]*[A-Z]'
__________________
Mike
Reply With Quote
  #3 (permalink)  
Old 03-31-10, 04:21
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
consider using the MySQL string functions UPPER and LOWER
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #4 (permalink)  
Old 03-31-10, 04:40
andy982183 andy982183 is offline
Registered User
 
Join Date: Mar 2010
Posts: 18
Quote:
Originally Posted by mike_bike_kite View Post

Usually MySQL is set up to ignore case. I believe what you need to use are regular expressions. I think something like this will do it for you:
Code:
select name from YourTable where name regexp '[A-Z][a-z]*[A-Z]'
Hello mike,

Thanks for ur reply.

I tried ur query, but it displays all records except null values

any different solution for this problem ?

Thanks
Reply With Quote
  #5 (permalink)  
Old 03-31-10, 04:57
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
You may need to use the binary keyword (I'd experiment a bit):
Code:
select name from YourTable where name regexp BINARY '[A-Z][a-z]*[A-Z]'
__________________
Mike
Reply With Quote
  #6 (permalink)  
Old 03-31-10, 05:27
andy982183 andy982183 is offline
Registered User
 
Join Date: Mar 2010
Posts: 18
Quote:
Originally Posted by mike_bike_kite View Post
You may need to use the binary keyword (I'd experiment a bit):
Code:
select name from YourTable where name regexp BINARY '[A-Z][a-z]*[A-Z]'
Hey Mike,

I tried this query.
It displays UPPER as well as Mixed case records.
It's works for me.

Thanks a lot for ur help
Reply With Quote
  #7 (permalink)  
Old 03-31-10, 07:19
mike_bike_kite mike_bike_kite is offline
vaguely human
 
Join Date: Jun 2007
Location: London
Posts: 2,519
Sorry, thought you wanted those as well (3rd time lucky):
Code:
select name from YourTable where name regexp BINARY '[A-Z][a-z]+[A-Z]'
__________________
Mike
Reply With Quote
  #8 (permalink)  
Old 03-31-10, 07:39
andy982183 andy982183 is offline
Registered User
 
Join Date: Mar 2010
Posts: 18
Quote:
Originally Posted by mike_bike_kite View Post
Sorry, thought you wanted those as well (3rd time lucky):
Code:
select name from YourTable where name regexp BINARY '[A-Z][a-z]+[A-Z]'
hey thanks a lot mike.
u made my day !
Reply With Quote
  #9 (permalink)  
Old 03-31-10, 08:00
Ikviens Ikviens is offline
Registered User
 
Join Date: Mar 2006
Posts: 55
Quote:
Originally Posted by healdem View Post
consider using the MySQL string functions UPPER and LOWER
Like this?

Code:
SELECT name
  FROM table
 WHERE NOT name IN (UPPER(name), LOWER(name))
Reply With Quote
  #10 (permalink)  
Old 03-31-10, 08:08
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
or for efficiency and speed, store the a column of this data in either upper or lower case and query it accordingly, this way you use the index.
Dave
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On