How to find max value in db column?

26 views
Skip to first unread message

smtu...@gmail.com

unread,
Mar 6, 2018, 5:39:41 PM3/6/18
to redbeanphp

I want to search a db column for the highest value and return it.

I tried:

$sql = R::exec('SELECT MAX(featured_order_id) FROM ads');

But no luck.

There is another (working) piece of code in the same function that looks like:

$count = R::count('ads', " featured_order_id=$order_id ", array('featured_order_id'=>$order_id));

Do I need to follow this pattern?

Anak1

unread,
Mar 7, 2018, 10:21:29 AM3/7/18
to redbeanphp
Look R::getCell
Reply all
Reply to author
Forward
0 new messages