Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
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

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 chanting in the Monastery: (3)
As of 2016-09-30 22:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (574 votes). Check out past polls.