Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Number of elements in array

by NetWallah (Abbot)
on Sep 24, 2012 at 13:55 UTC ( #995388=note: print w/ replies, xml ) Need Help??


in reply to Number of elements in array

If you want to get the number of rows in a database table, the most efficient way would be to let the database count them:

...prepare ("Select COUNT(*) FROM TABLE_OR_QUERY"); # TABLE_OR_QUERY can be another (SELECT...) statement
Most databases will optimize queries, so you can do the count query, then do the data query as 2 separate queries.

             I hope life isn't a big joke, because I don't get it.
                   -SNL


Comment on Re: Number of elements in array
Download Code
Replies are listed 'Best First'.
Re^2: Number of elements in array
by tobyink (Abbot) on Sep 24, 2012 at 14:03 UTC

    This counts the number of rows. The OP was counting the number of columns.

    Of course, it's possible that the OP did actually want the number of rows...

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://995388]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (6)
As of 2015-07-29 04:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls