How would you return the highest number of a mysql query in PHP?
Say i had a query that was "select email from users". I’ve selected the whole column of "email". How would i return the highest number in that whole field? Is that even possible?
The highest number? I’m not sure I understand what you’re after. Wouldn’t the email field be a text data type, as opposed to a numerical data type?
If for some reason you’ve named a numerical field "email", you could just for SELECT * FROM `users` ORDER BY `email` DESC LIMIT 1; or just SELECT MAX(`email`) FROM `users`;. That would give you the highest value in a numerical column.
use the sql MAX command.
http://www.plus2net.com/sql_tutorial/sql_max.php
References :
The highest number? I’m not sure I understand what you’re after. Wouldn’t the email field be a text data type, as opposed to a numerical data type?
If for some reason you’ve named a numerical field "email", you could just for SELECT * FROM `users` ORDER BY `email` DESC LIMIT 1; or just SELECT MAX(`email`) FROM `users`;. That would give you the highest value in a numerical column.
References :