Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Select COUNT in MySQL

by tchatzi (Acolyte)
on Jun 09, 2005 at 10:24 UTC ( #465047=note: print w/ replies, xml ) Need Help??


in reply to Select COUNT in MySQL

First of all you Have to use prepare and execute with select.
Only with select though, it makes the execution of the whole thing faster.
With everything else use 'do'

and second to do what you want, do it like this (the right way....)

my $dbh = DBI->connect('DBI:mysql:foo','foo','foo') or die "Connect Error: $DBI::errstr"; my $count_sth = $dbh->prepare("SELECT COUNT(*) FROM company_info;") or die "Prepare Count Error: $DBI::errstr\n"; $count_sth->execute() or die "Execute Count Error: $DBI::errstr\n"; print $count_sth->fetchrow; $count_sth->finish; $dbh->disconnect;

Isn't it simple ?

``The wise man doesn't give the right answers, he poses the right questions.'' TIMTOWTDI


Comment on Re: Select COUNT in MySQL
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2014-04-19 19:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (483 votes), past polls