Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: using fetchrow_hashref

by maverick (Curate)
on Dec 30, 2003 at 19:47 UTC ( #317757=note: print w/replies, xml ) Need Help??

in reply to using fetchrow_hashref

Chang your SQL query to read:
SELECT code, sum(number) as foobar FROM $serverTabl_4 group by code
and then use 'foobar' in the hash ref.

Basically, the keys are whatever it thinks the column name if you use 'sum(column)', 'avg(column)' or the like, it names the key that. If you tack on the 'as something_else' after it, you can effectively name the keys whatever you like. This is also handy when you have a join across two tables that have similarily named columns :)


Update: Heh. 3rd fastest keys in the west...

Replies are listed 'Best First'.
Re: Re: using fetchrow_hashref
by Baz (Friar) on Dec 30, 2003 at 19:55 UTC
    Cool, thanks guys.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://317757]
and the voices are still...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2017-01-17 05:47 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (152 votes). Check out past polls.