how to lookup last record in dataset in Mnesia?

Gaspar Chilingarov nm@REDACTED
Wed Jun 7 13:55:23 CEST 2006

Hello all!

I have a table in Mnesia, which I with to filter by some field(s) and
fetch one record with maximal ID (ie. last inserted).

The only method I can imagine -

make qlc query, sort it by ID in reverse order, create qlc cursor and
fetch exactly  1 record from resulting dataset.

(SQL equivalent: SELECT MAX(ID) FROM table WHERE foo_field = 'bar' and
user_name = 'Alice')

Are there any fast ways to achieve this in mnesia?

Thanks in advance, Gaspar

Gaspar Chilingarov

System Administrator,
Network security consulting

t +37493 419763 (mob)
i 63174784

More information about the erlang-questions mailing list