方法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}]).