Question

I am using MySQL with Flourish. Let's suppose I have a table called Foo and it has a column called id. My question is:

What is the flourish equivalent for the following query:

select * from Foo where id = (select max(id) from Foo);

Thanks

Was it helpful?

Solution

This works:

public static function getLastFoo() {
    return fRecordSet::build('Foo')->sort('getId', 'desc')->getRecord(0);
}

OTHER TIPS

There is not better way with ORDER BY and LIMIT?

SELECT * FROM Foo ORDER BY id DESC LIMIT 1

Use DESC for highest value.

Try:

select max(id),foo.* from foo order by id desc limit 1
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top