In my mysql data is something like this

Name 1.0
Name 6.0
Name 5.2
Name 4.8
Name 10.00.258

now when I short that column it shows up like

Name 6.0
Name 5.2
Name 4.8
Name 1.0
Name 10.00.258

I want that 10 to be on top Is there any way around this?

A proper table design would prevented this problem.

The first rule of relational database design:
- You should never store more than one piece of data in a single field.

Your fields are storing two pieces of information. A name and a number.

As a result, the number is being treated by MySQL as a string. And as a string, the *number* is being sorted one character at a time, placing 10 with 1.

If you were to split the number into it's own integer field, you could have MySQL sort the results based on the string first, and then the number. That way it would sort it by the entire number, not one char at a time.

I recommend you read this article. It describes the three basic rules of database design. Will help you avoid these sort of problems.

You have to SELECT statement and want to order it by a field which is a float.
So results is like....

2.05
2.3
2.4
2
Use order by ...

Yep this helped a lot. Thank you guys.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.