0
我有这种形式的SQL结果:分配多个SQL结果值相同的密钥
Id Amount1 Amount2 Amount3
1 10 10 12
2 20 13 14
3 30 15 15
我想的Id的项和所有其他值存储在值
这样的事情:
{1=>{:Amount1=>"10", :Amount2=>"10", :Amount3=>"12"}, 2=>{:Amount1=>"20", :Amount2=>"13", :Amount3=>"14"}}
这是我目前有至今:
hashn = Hash.new
sqlresult.each { |x|
hashn[x['PPS_Id']] = x['Gift_Card_Amount1']
hashn[x['PPS_Id']] = x['Gift_Card_Amount2']
hashn[x['PPS_Id']] = x['Gift_Card_Amount3']
}
我相信这覆盖了以前的价值,请你帮忙。