473,385 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

ORDER BY

I have this list that i'm ordering by units_unit_id and is there way I can get
a natural order so that D4 and D5 comes before D12

Thanks,
Matt

+---------------+
| units_unit_id |
+---------------+
| D1 |
| D12 |
| D14 |
| D15 |
| D16 |
| D18 |
| D19 |
| D4 |
| D5 |
+---------------+
Jul 20 '05 #1
12 4101
Matias Silva wrote:
I have this list that i'm ordering by units_unit_id and is there way I
can get
a natural order so that D4 and D5 comes before D12


It is not a natural order, natural order is the one you are getting.
Easy way would be to change the table so that D and number would be in
different columns. Another way is to use some string manipulation
functions to parse string into character and a number and then order by
number. This might mean slow queries if you have many rows in your table
so first solution is better if it is possible to do.

left() right() and length() functions atleast are able to to do this.
I'm not sure if there is a better way to do it, you can look for such
functions from the manual:

http://dev.mysql.com/doc/mysql/en/String_functions.html
Jul 20 '05 #2
Matias Silva wrote:
I have this list that i'm ordering by units_unit_id and is there way I
can get
a natural order so that D4 and D5 comes before D12


It is not a natural order, natural order is the one you are getting.
Easy way would be to change the table so that D and number would be in
different columns. Another way is to use some string manipulation
functions to parse string into character and a number and then order by
number. This might mean slow queries if you have many rows in your table
so first solution is better if it is possible to do.

left() right() and length() functions atleast are able to to do this.
I'm not sure if there is a better way to do it, you can look for such
functions from the manual:

http://dev.mysql.com/doc/mysql/en/String_functions.html
Jul 20 '05 #3
Matias Silva wrote:
I have this list that i'm ordering by units_unit_id and is there way I
can get
a natural order so that D4 and D5 comes before D12


It is not a natural order, natural order is the one you are getting.
Easy way would be to change the table so that D and number would be in
different columns. Another way is to use some string manipulation
functions to parse string into character and a number and then order by
number. This might mean slow queries if you have many rows in your table
so first solution is better if it is possible to do.

left() right() and length() functions atleast are able to to do this.
I'm not sure if there is a better way to do it, you can look for such
functions from the manual:

http://dev.mysql.com/doc/mysql/en/String_functions.html
Jul 20 '05 #4
Great point Aggro...
My 2cents...
natural order for me is D01, D02, D03... D12, D13.. etc.

"Aggro" <sp**********@yahoo.com> wrote in message
news:Pe************@read3.inet.fi...
Matias Silva wrote:
I have this list that i'm ordering by units_unit_id and is there way I
can get
a natural order so that D4 and D5 comes before D12


It is not a natural order, natural order is the one you are getting.
Easy way would be to change the table so that D and number would be in
different columns. Another way is to use some string manipulation
functions to parse string into character and a number and then order by
number. This might mean slow queries if you have many rows in your table
so first solution is better if it is possible to do.

left() right() and length() functions atleast are able to to do this.
I'm not sure if there is a better way to do it, you can look for such
functions from the manual:

http://dev.mysql.com/doc/mysql/en/String_functions.html

Jul 20 '05 #5
Great point Aggro...
My 2cents...
natural order for me is D01, D02, D03... D12, D13.. etc.

"Aggro" <sp**********@yahoo.com> wrote in message
news:Pe************@read3.inet.fi...
Matias Silva wrote:
I have this list that i'm ordering by units_unit_id and is there way I
can get
a natural order so that D4 and D5 comes before D12


It is not a natural order, natural order is the one you are getting.
Easy way would be to change the table so that D and number would be in
different columns. Another way is to use some string manipulation
functions to parse string into character and a number and then order by
number. This might mean slow queries if you have many rows in your table
so first solution is better if it is possible to do.

left() right() and length() functions atleast are able to to do this.
I'm not sure if there is a better way to do it, you can look for such
functions from the manual:

http://dev.mysql.com/doc/mysql/en/String_functions.html

Jul 20 '05 #6
Great point Aggro...
My 2cents...
natural order for me is D01, D02, D03... D12, D13.. etc.

"Aggro" <sp**********@yahoo.com> wrote in message
news:Pe************@read3.inet.fi...
Matias Silva wrote:
I have this list that i'm ordering by units_unit_id and is there way I
can get
a natural order so that D4 and D5 comes before D12


It is not a natural order, natural order is the one you are getting.
Easy way would be to change the table so that D and number would be in
different columns. Another way is to use some string manipulation
functions to parse string into character and a number and then order by
number. This might mean slow queries if you have many rows in your table
so first solution is better if it is possible to do.

left() right() and length() functions atleast are able to to do this.
I'm not sure if there is a better way to do it, you can look for such
functions from the manual:

http://dev.mysql.com/doc/mysql/en/String_functions.html

Jul 20 '05 #7
bobb wrote:
Great point Aggro...
My 2cents...
natural order for me is D01, D02, D03... D12, D13.. etc.


...., D99, D100, etc.
--
Eric Lafontaine
mail http://cerbermail.com/?WaqHmkTe5E
Jul 20 '05 #8
bobb wrote:
Great point Aggro...
My 2cents...
natural order for me is D01, D02, D03... D12, D13.. etc.


...., D99, D100, etc.
--
Eric Lafontaine
mail http://cerbermail.com/?WaqHmkTe5E
Jul 20 '05 #9
bobb wrote:
Great point Aggro...
My 2cents...
natural order for me is D01, D02, D03... D12, D13.. etc.


...., D99, D100, etc.
--
Eric Lafontaine
mail http://cerbermail.com/?WaqHmkTe5E
Jul 20 '05 #10
Yea to me natural order is what bobb has described. I think I'll just
restructure the table so that the table building and unit IDs are separate.

Thanks,
Matt

bobb wrote:
Great point Aggro...
My 2cents...
natural order for me is D01, D02, D03... D12, D13.. etc.

"Aggro" <sp**********@yahoo.com> wrote in message
news:Pe************@read3.inet.fi...
Matias Silva wrote:

I have this list that i'm ordering by units_unit_id and is there way I
can get
a natural order so that D4 and D5 comes before D12


It is not a natural order, natural order is the one you are getting.
Easy way would be to change the table so that D and number would be in
different columns. Another way is to use some string manipulation
functions to parse string into character and a number and then order by
number. This might mean slow queries if you have many rows in your table
so first solution is better if it is possible to do.

left() right() and length() functions atleast are able to to do this.
I'm not sure if there is a better way to do it, you can look for such
functions from the manual:

http://dev.mysql.com/doc/mysql/en/String_functions.html


Jul 20 '05 #11
Yea to me natural order is what bobb has described. I think I'll just
restructure the table so that the table building and unit IDs are separate.

Thanks,
Matt

bobb wrote:
Great point Aggro...
My 2cents...
natural order for me is D01, D02, D03... D12, D13.. etc.

"Aggro" <sp**********@yahoo.com> wrote in message
news:Pe************@read3.inet.fi...
Matias Silva wrote:

I have this list that i'm ordering by units_unit_id and is there way I
can get
a natural order so that D4 and D5 comes before D12


It is not a natural order, natural order is the one you are getting.
Easy way would be to change the table so that D and number would be in
different columns. Another way is to use some string manipulation
functions to parse string into character and a number and then order by
number. This might mean slow queries if you have many rows in your table
so first solution is better if it is possible to do.

left() right() and length() functions atleast are able to to do this.
I'm not sure if there is a better way to do it, you can look for such
functions from the manual:

http://dev.mysql.com/doc/mysql/en/String_functions.html


Jul 20 '05 #12
Yea to me natural order is what bobb has described. I think I'll just
restructure the table so that the table building and unit IDs are separate.

Thanks,
Matt

bobb wrote:
Great point Aggro...
My 2cents...
natural order for me is D01, D02, D03... D12, D13.. etc.

"Aggro" <sp**********@yahoo.com> wrote in message
news:Pe************@read3.inet.fi...
Matias Silva wrote:

I have this list that i'm ordering by units_unit_id and is there way I
can get
a natural order so that D4 and D5 comes before D12


It is not a natural order, natural order is the one you are getting.
Easy way would be to change the table so that D and number would be in
different columns. Another way is to use some string manipulation
functions to parse string into character and a number and then order by
number. This might mean slow queries if you have many rows in your table
so first solution is better if it is possible to do.

left() right() and length() functions atleast are able to to do this.
I'm not sure if there is a better way to do it, you can look for such
functions from the manual:

http://dev.mysql.com/doc/mysql/en/String_functions.html


Jul 20 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: svilen | last post by:
hello again. i'm now into using python instead of another language(s) for describing structures of data, including names, structure, type-checks, conversions, value-validations, metadata etc....
9
by: Steven T. Hatton | last post by:
The following works: template <typename T> struct ID3M{ static const T ID; }; template <typename T> const T ID3M<T>::ID = {{1,0,0},{0,1,0},{0,0,1}};
15
by: | last post by:
The data file is a simple Unicode file with lines of text. BCP apparently doesn't guarantee this ordering, and neither does the import tool. I want to be able to load the data either sequentially...
27
by: Abdullah Kauchali | last post by:
Hi folks, Can one rely on the order of keys inserted into an associative Javascript array? For example: var o = new Object(); o = "Adam"; o = "Eve";
8
by: kaosyeti | last post by:
i have a (hopefully) small problem. i have created a system where a user enters customer information into a table through a form. this table has no primary key. there are 9 fields on the form to...
104
by: Beowulf | last post by:
I have the view below and if I use vwRouteReference as the rowsource for a combo box in an MS Access form or run "SELECT * FROM vwRouteReference" in SQL Query Analyzer, the rows don't come through...
13
by: bevanward | last post by:
Hi All I am finding unexpected results when inserted into a newly created table that has a field of datatype int identity (1,1). Basically the order I sort on when inserting into the table is...
3
by: Hartmut Dippon | last post by:
Hi all, I hope somebody can help me with following problem: I have an application where I can drag&drop files/dirs from within explorer onto my form. If multiple files/dirs are selected I...
54
by: Rasjid | last post by:
Hello, I have just joined and this is my first post. I have never been able to resolve the issue of order of evaluation in C/C++ and the related issue of precedence of operators, use of...
25
by: DanicaDear | last post by:
Hello again Bytes...I missed you! First, background: In a hotstick lab, we ship orders every two years. We ship a new order and the customer uses the new box to return the previous year's order....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.