From: 7stud -- Date: 2012-12-13T08:39:43+09:00 Subject: Re: Database query cristian cristian wrote in post #1088899: > > and then just use this like I did with the hash above but it doesnt > work: > > store_as_hash.each do |number,url| > if number == "1" > .... > else > .... > end > db.results_as_hash = true result_set = db.execute( "SELECT Key,Url FROM Sites" ) result_set.each do |row| row.each { |key, value| puts "#{key} => #{value}" } puts '*' * 20 end --output:-- Key => 1 Url => www.cool.com 0 => 1 1 => www.cool.com ******************** Key => 2 Url => www.bad.com 0 => 2 1 => www.bad.com ******************** Key => 3 Url => www.avg.com 0 => 3 1 => www.avg.com ******************** Note that results_as_hash lets you access the results by index value too, so there are additional keys for the indexes. -- Posted via http://www.ruby-forum.com/.