Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://465047]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2018-03-20 07:04 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (248 votes). Check out past polls.