Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2015-12-01 23:10 GMT
Find Nodes?
    Voting Booth?

    My keyboard shows this many letters:

    Results (29 votes), past polls