I tried this query
$sql = mysql_query("SELECT * FROM tblPlantilla ORDER
BY left(itemNumber, instr(itemNumber, '-')),
mid(itemNumber, instr(itemNumber, '-')+1) ASC");
but I didn't get the correct output :(
This is the output...
1
2
1-1
1-2
1-3
1-10
1-11
1-12
2-1
Here is another sample data and the corresponding
output
1-3
1-10
1-11
1-12
1
1-1
1-2
2-1
2
the output should be...
1
1-1
1-2
1-3
1-10
1-11
1-12
2
2-1
Please help me... thank you...
--- Pete <[EMAIL PROTECTED]> wrote:
> In message
> <[EMAIL PROTECTED]>,
> edgardo
> catorce <[EMAIL PROTECTED]> writes
> >Good day!
> >
> >I have a problem... I want to sort and print
> records..
> >say for example...
> >
> >1-3
> >1-10
> >1-11
> >1-12
> >1-1
> >1-2
> >
> >the output should be...
> >
> >1-1
> >1-2
> >1-3
> >1-10
> >1-11
> >1-12
> >
> >when i sorted it by ascending order.. the output
> is:
> >
> >1-10
> >1-11
> >1-12
> >1-1
> >1-2
> >1-3
> >
> >Please help me. Thank you...
>
> Please explain how the data is stored, and assuming
> it is in a database,
> what sort of database.
>
> The problem is that the data is being treated as a
> string, and you want
> it to be treated as a number.
>
> If this is one field, then you might need to split
> it, using substring.
> The second part of the string could be turned into a
> number, using cast.
>
> It would be better if you could put the data in two
> fields, each
> numeric, then your sort would be quicker. I always
> try to get any
> "complicated" bits, like splitting or combining,
> into the INSERT side,
> so that when the user is retrieving data, it is
> quicker.
>
> --
> Pete Clark
>
> Sunny Andalucia
> http://hotcosta.com/Andalucia.Spain
>
____________________________________________________________________________________
Be a better sports nut! Let your teams follow you
with Yahoo Mobile. Try it now.
http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ