Skip to content
Advertisement

Get least 10 values in mysql query

Database table.

I have a table in mysql. Table Name is constitutive_table, it contains more than 40 columns and its type is varchar, it contains more than 25000 records. I wrote the query like this to get the 10 least value. But it showing like as you have seen in the picture.

Advertisement

Answer

The data in the Brain column appears to be floating point, so you should be casting to the appropriate type:

Most likely what is happening now is that the 10 values you see all have the same value when cast to integer. As a result, MySQL is using some secondary sort to generate the order you do see.

While the above query may resolve your problem, ideally you should change the Brain column to some numeric type.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement