Matthew
Matthew

Reputation: 1655

Incorrect sorting in Laravel and MySQL

I'm under the assumption others have faced this issue before, and maybe I am just using the incorrect terminology to search by in this instance. I have a table in my MySQL database where I want to pull the largest (highest or max) number in a column (not the main ID column though), however, it sorts like this:

And below is the image of my column. At this point, if someone has a suggestion just from a PHP/MySQL suggestion, I'm willing to take it and can go from there, however from the Laravel point of view, I am using:

$MaxProNo = DB::table('Shipments')->max('pro_number');

to pull that number.

MySQL Database Table Column

Upvotes: 2

Views: 298

Answers (1)

MCMXCII
MCMXCII

Reputation: 1026

You need to change the format of your db column from VARCHAR to INT.

Upvotes: 2

Related Questions