Jump to content

Recommended Posts

Hey,

 

I have a bunch of fields with unusual strings of numbers seperated by symbols (used for php explode stuff at later parts of my script)...

 

But i was wondering if there is a way mysql can order the data even though they are invalid integers/decimals.

 

The values are like this:

 

5:14:1+3+4+6+7

5:14:1+2+5+6+7

5:13:1+2+3+8+13

 

But i need them to order by DESC by comparing the numbers going from left to right (in a way - ignoring the : and the + symbols)How is this done?

Link to comment
https://forums.phpfreaks.com/topic/217282-order-by-customised/
Share on other sites

You would need to produce a value where the same position in each string has the same significance. That would require that every field making up the value has the same length. You could then directly compare the values as strings (even with the : and + still in them) because each character position in a string has the same significance/magnitude as that same character position in the other string(s).

 

What are the maximum number of possible digits for each number within that data? You are implying 2 (the :13, :14, and +13)

 

Edit: The short answer would be if you were to include leading zero's on each number/field making up the values when they are stored, so that each stored value has the same length/format, you could ORDER BY them directly.

 

 

Link to comment
https://forums.phpfreaks.com/topic/217282-order-by-customised/#findComment-1128321
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.