You can use mnesia:foldl/foldr probably. But this will traverse the
entire table everytime. Alternately, you could use an ordered_set table
and then use mnesia:dirty_last - but I don't think it meets your needs
from what you've said.<br>
<br>
Chandru<br><br><div><span class="gmail_quote">On 07/06/06, <b class="gmail_sendername">Gaspar Chilingarov</b> <<a href="mailto:nm@web.am">nm@web.am</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello all!<br><br><br>I have a table in Mnesia, which I with to filter by some field(s) and<br>fetch one record with maximal ID (ie. last inserted).<br><br>The only method I can imagine -<br><br>make qlc query, sort it by ID in reverse order, create qlc cursor and
<br>fetch exactly 1 record from resulting dataset.<br><br>(SQL equivalent: SELECT MAX(ID) FROM table WHERE foo_field = 'bar' and<br>user_name = 'Alice')<br><br>Are there any fast ways to achieve this in mnesia?<br><br>Thanks in advance, Gaspar
<br><br>--<br>Gaspar Chilingarov<br><br>System Administrator,<br>Network security consulting<br><br>t +37493 419763 (mob)<br>i 63174784<br>e <a href="mailto:nm@web.am">nm@web.am</a><br></blockquote></div><br>