Requiring mysql Query to find range [Resolved]

Posted by Thiru under Others on 4/21/2012 | Points: 10 | Views : 921 | Status : [Member] | Replies : 4
Hi Friends,

Required query is:

select Bno from table1 where (Bno between 'CHM0000010' and 'CHM0000020') order by Bno

Note: Table1 is having business number "Bno" its varchar(15) (like: CHM0000010,CHM0000011,CHM0000012....)

it not working ...
hope you understand my requirement - pls. help me in this regard.




Responses

Posted by: Gsm_Gsv on: 4/21/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
Try this

SELECT Bno 

FROM table1
WHERE Bno BETWEEN 'CHM0000010' AND 'CHM0000020'
ORDER BY Bno ASC


If you dont get, plz post the error you are getting.

---------------------------------------
Live the life you've dreamed

Regards
MADHU

Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Thiru on: 4/21/2012 [Member] Starter | Points: 25

Up
0
Down
My God, Madhu i need explanation for this query too :-)

Its working fine but what is the difference between your query and mine ?

By default is Asc know in "order by" tag

i mean:
Order by Bno
Order by Bno Asc

Both are same know.


Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gsm_Gsv on: 4/21/2012 [Member] Starter | Points: 25

Up
0
Down
I think it may be because of brackets, but not sure about that..

---------------------------------------
Live the life you've dreamed

Regards
MADHU

Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Thiru on: 4/21/2012 [Member] Starter | Points: 25

Up
0
Down
No, even i try without brackets.

Thiru, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response