Getting a single hash from a row in a MySQL query

Hi, all. Right now, when I want to pull a hash out of a database, I
find myself first pulling all matching rows from my select, then
iterating through all the hashes in a given row. Surely, when I’ve got
a row, I should be able to say something akin to
puts row[“foo”]
and have it spit out its value, “bar”, instead of doing what I am right
now, which is

row.each_pair do |key, value|
stuff happens here
end

Pointers? (And apologies if this is a totally newb kind of
question…)

Thanks!

-Ken

Ken D’Ambrosio wrote in post #1092440:

Hi, all. Right now, when I want to pull a hash out of a database,

You don’t pull hashes out of databases. You select rows.

I
find myself first pulling all matching rows from my select, then
iterating through all the hashes in a given row.

Rows do not have ‘hashes’; they have columns.

Surely, when I’ve got
a row, I should be able to say something akin to
puts row[“foo”]
and have it spit out its value, “bar”, instead of doing what I am right
now, which is

row.each_pair do |key, value|
stuff happens here
end

Pointers? (And apologies if this is a totally newb kind of
question…)

Thanks!

-Ken

results.each do |row|
puts row[‘column_name’]
end