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 > Range

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-21-11, 09:43
narayanyr narayanyr is offline
Registered User
 
Join Date: Apr 2010
Posts: 30
Range

Hi,
I have a range of values in a column in this format

0-4
4-8
8-12
12-16
16-20
20-24
24-28
28-32
32-36
36-40
40-44
44-48
48-52
52-56
56-60
60-64
64-68
68-72
72-76
76-80
80-84
84-88
88-92
92-96
96-100

Now how do I retreive and maintain data in the same sequence?

When I run a select * query the data is retreived as

0-4
12-16
16-20
20-24
24-28
28-32
32-36
36-40
4-8
40-44
44-48
48-52
52-56
56-60
60-64
64-68
68-72
72-76
76-80
8-12
80-84
84-88
88-92
92-96
96-100

So as we see the sequence is different I want the data to be retreived in the first format shown.Kindly help me with a query or procedure to do the same.

Thanks in advance
Reply With Quote
  #2 (permalink)  
Old 03-21-11, 09:51
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,535
Quote:
Originally Posted by narayanyr View Post
I have a range of values in a column in this format
there's your problem right there

use two integer columns -- range_from and range_to
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 03-21-11, 10:21
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
or if you must insist on your current design, make certtian you write the values either zero or space padded. so if you thinkt hre number range is going to be say 1..999, then at the very least store 1 or two orders of magnitude so for upto 999 I'd suggest store as 00999.

but thats a kludge worksaround bad design, do as r937 says and dtore the two values as discrete numbers
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #4 (permalink)  
Old 03-21-11, 23:43
narayanyr narayanyr is offline
Registered User
 
Join Date: Apr 2010
Posts: 30
Correct.....I am trying to incorporate the values in a bar chart as x axis.So all values in the column that I refer to in the previous mail would be the values in x-axis.In this case I may not be able to prefix a zero to a value say "04-08".Is there any other way out of this problem?
Reply With Quote
  #5 (permalink)  
Old 03-22-11, 03:45
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
why do you think 'you may not be able to prefix a zero', have you tried?

what generates the ranges?

fix the problem there, or fix it at source, fixing at a later stage is a PIA, is fraught with problems and means you need to apply the same fix elsewhere whne you need to use the same data subset.
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
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