????Mnesia????????????????????????????????????????????к????????????Erlang????????????????????????Mnesia??????????????й???????????????????????????? ????? Mnesia ?????????
????????б??????壺
????%% ?????
????-record( y_account??{ id?? account?? password }).
????%% ??????
????-record( y_info?? { id?? nickname?? birthday?? sex }).
????1??Select ???
?????????????
%%===============================================
%%  select * from y_account
%%===============================================
%% ??? mnesia:select
F = fun() ->
MatchHead = #y_account{ _ = '_' }??
Guard = []??
Result = ['$_']??
mnesia:select(y_account?? [{MatchHead?? Guard?? Result}])
end??
mnesia:transaction(F).
%% ??? qlc
F = fun() ->
Q = qlc:q([E || E <- mnesia:table(y_account)])??
qlc:e(Q)
end??
mnesia:transaction(F).
?????????????ε???
%%===============================================
%%  select id??account from y_account
%%===============================================
%% ??? mnesia:select
F = fun() ->
MatchHead = #y_account{id = '$1'?? account = '$2'?? _ = '_' }??
Guard = []??
Result = ['$$']??
mnesia:select(y_account?? [{MatchHead?? Guard?? Result}])
end??
mnesia:transaction(F).
%% ??? qlc
F = fun() ->
Q = qlc:q([[E#y_account.id?? E#y_account.account] || E <- mnesia:table(y_account)])??
qlc:e(Q)
end??
mnesia:transaction(F).