How would I go about this? I want to display the largest value from the column
SELECT max(field) FROM table
A better performing query on MVCC databases like postgresql is to use:
select id from table order by id desc limit 1
PostgreSQL can't use indexes on aggregate functions, but can on a limit clause.
I get "Resource id #5". I know that it is working, but how to make it display the integer
Which DBMS are you using?
Basically, you need to extract the data from the result set returned (as a resource in PHP).
MySQL
Hi,
you need to do something like e.g.
$res = mysql_query("SELECT MAX(field) AS num FROM table"); $row = mysql_fetch_array($res); $max = $row['num'];
Thomas
Thank you everyone who helped me out. It works beautifuly