Jump to content

Order sql results table by weigth [SOLVED]


ARV187

Recommended Posts

Hi all,

Im trying make a aircraft table, the only part that fault me is order by weight.

The data not is been order correctly (see image):

post-5667-0-00854000-1385902478_thumb.jpg


............ FROM phpvms_aircraft ORDER BY phpvms_aircraft.weight";

Seems that fail is in order number by number and not full cuantity. Ex, order by weight ASC:

12005324 (the fourth digit is smaller than 3)

1203 (the fourth digit is bigger than 0)

The heavier aircraft is ordained as the lightest

How i can resolve this?

Thanks, regards...

Link to comment
Share on other sites

Hi itrobb, then to a homemade table what is the correct place in forum?

About my question, yes, that is my code, but not work because compare digit by digit, not the full number.

Only i find one solution, set all weight aircraft with same digit numbers. But is a long work.

Link to comment
Share on other sites

See the attached image in first post, in mysql is sorted wrong, because makes a comparison number by number, not by the total amount.For example, with tu154 & extra300, the heavy aircraft is tu154, but he compare digit by digit:

122000

1342

1 & 1 (same number), 2 & 3 (three is greater than two) then sql sort the extra-300 (1342lbs) in second place because in their opinion is greater.

Only work if i put the same number of digits, For example six digits: Tu-154 (122000) and extra-300 (001342)

Edited by ARV187
Link to comment
Share on other sites

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.

Loading...
×
×
  • Create New...