Saturday, September 18, 2021

Finding the MySQL MAX number in Joomla Database

I needed to find the max number in my Joomla Database and increment this by one. Here is the code I used that ended up working for me.

// Get the highest ticket number and add 1
$db = JFactory::getDbo();
$query = $db->getQuery(true);
->order(‘number ASC’)
$my_value = $db->loadResult();
// Add 1
$next_num = ($my_value + 1);

I found this link that helped me figure it out.

I hope this helps someone else…


Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.