I have a SQL Database that has a column like this:
ID
-----
0352
5432
4382
3520
30593
3992
295
What I want to do is search through that column, find the largest number (30593) and store it in a variable.
This database has other columns, the example above is for demonstration only.
e.g.
$largestNumber = GET LARGEST NUMBER FROM ID
How would I do that in PHP / MySQL
SELECT MAX(ID) FROM TABLE
Execute the statement and assign it to your variable.
Try This Query
I believe
SELECT max(id) FROM table
will work.Use
MAX(ID)
to get the largest valueIn PHP, we do it like this:
You can do a single query to figure this out:
http://www.tutorialspoint.com/mysql/mysql-max-function.htm
MySql has it's own Max function that will return the highest value in the specified column.