当前位置: 代码迷 >> 综合 >> mnesia 简单查询
  详细解决方案

mnesia 简单查询

热度:62   发布时间:2024-01-14 11:05:58.0
方法1:
F = fun () ->
MatchHead = #person{name='$1', sex=male, age='$2', _='_'},
Guard = [{'>', '$2', 30}],
Result = ['$1'],
mnesia:select(Tab,[{MatchHead, Guard, Result}])
end ,
mnesia:transaction(F).
 
  
方法二
MatchHead = #person{name='$1', sex=male, age='$2', _='_'},  % 也可包含等于条件   name=Name
Guard = [{'>', '$2', 30}], %条件 > == <
Result = ['$1'],  %结果  '$n'返回变量$n;'$$'返回所有  $变量;  '$_'返回整行;
mnesia:dirty_select(Tab,[{MatchHead, Guard, Result}]).