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 > Sorting records in lower case

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-31-10, 06:01
andy982183 andy982183 is offline
Registered User
 
Join Date: Mar 2010
Posts: 18
Question Sorting records in lower case

Hello,

I am working on a query, It finds records which are in lower case from table.

eg.

richard
john
andy

The below query which I have designed, shows the required output...
but fields containing numeric & null values are also displayed, which i don't require.

--
SELECT * FROM `table`
WHERE (NAME COLLATE latin1_bin ) = lower(NAME);
--

Kindly Advice
Thanks
Reply With Quote
  #2 (permalink)  
Old 03-31-10, 06:13
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
so exclude those rows by using an appropriate WHERE clause
eg AND NOT IS NULL(name)
and/or modify MIKE-BIKE-KITE's regexp to exclude numbers, although to be fair regexp is not for the faint hearted
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 03-31-10, 06:48
andy982183 andy982183 is offline
Registered User
 
Join Date: Mar 2010
Posts: 18
Quote:
Originally Posted by healdem View Post
so exclude those rows by using an appropriate WHERE clause
eg AND NOT IS NULL(name)
and/or modify MIKE-BIKE-KITE's regexp to exclude numbers, although to be fair regexp is not for the faint hearted
Hey Healdem,

Designed this query for lower case...and got fully working !!

SELECT * FROM `table`
WHERE NAME regexp BINARY'^[a-z]'


Thanks
Reply With Quote
  #4 (permalink)  
Old 03-31-10, 13:51
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,525
Quote:
Originally Posted by andy982183 View Post
Designed this query for lower case...and got fully working !!Thanks
your testing was not very rigourous, was it

try this --
Code:
CREATE TABLE test_mixedcase
( name VARCHAR(99)
);

INSERT INTO test_mixedcase (name) VALUES 
 ( 'this is all lower case' )
,( 'this starts in lower case AND THEN GOES UPPER' )
;
SELECT * FROM test_mixedcase
WHERE name REGEXP BINARY '^[a-z]'
tell me which rows it returned

hint: bofadem

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 03-31-10, 14:06
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,606
Code:
SELECT *
   FROM `table`
   WHERE name NOT LIKE '%[^a-z]%'
-PatP
__________________
In theory, theory and practice are identical. In practice, theory and practice are unrelated.
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