sql - MySQL checking a range of characters with char_length() not giving results -


select firstname        , lastname        , phone        , balance    customers   balance > 0     , phone != ''     , char_length(phone) > 10     , char_length(phone) < 11; 

this gives not results if

select firstname        , lastname        , phone        , balance     access_ayyaz_test.customers    balance > 0      , phone != ''      , char_length(phone) > 10; 

or

select firstname        , lastname        , phone        , balance     customers   balance > 0      , phone != ''      , char_length(phone) < 11; 

they give results on own not together. how can check range then?

the queries

select firstname        , lastname        , phone        , balance     access_ayyaz_test.customers    balance > 0      , phone != ''      , char_length(phone) > 10; 

and

select firstname        , lastname        , phone        , balance     customers   balance > 0      , phone != ''      , char_length(phone) < 11; 

are checking records phone numbers length greater 10 , less 11 respectively. having these queries return values doesn't makes condition char_length(phone) > 10 , char_length(phone) < 11 true.

there might records length of phone number 12, 13 or 14, makes condition char_length(phone) > 10 true , return records satisfying condition.

likewise, there might records length of phone number less 11 , makes condition char_length(phone) < 11 true , return records satisfying condition.

edit : per comment, if looking records phone numbers of length between 10 , 12, dont need 2 filters

 , char_length(phone) > 10   , char_length(phone) < 12 

as can simple use and char_length(phone) = 11.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -