[prev in list] [next in list] [prev in thread] [next in thread]
List: mysql
Subject: COUNT()
From: toxalot () canada ! com
Date: 1999-06-30 16:25:49
[Download RAW message or body]
I am trying to figure out how to use the COUNT() function. I am using perl
and DBI
I want to find out how many records are returned by this statement
SELECT main.pro_id,main.pro_name,main.city,main.province,main.type FROM
main,specials WHERE main.pro_id IN ($PRO_IDS) AND specials.pro_id IN
($SPEC_PRO_IDS) AND main.pro_id=specials.pro_id GROUP BY pro_name
If I add a COUNT(*) into the first part of the SELECT and bind it to a
variable like I did the others, I get a count of 3 when there are about
1000 records returned.
Here is an excerpt of my code. I would like to print out the total number
of records at the top before I print the list of them.
$sql="SELECT main.pro_id,main.pro_name,main.city,main.province,main.type
FROM main,specials WHERE main.pro_id IN ($PRO_IDS) AND specials.pro_id IN
($SPEC_PRO_IDS) AND main.pro_id=specials.pro_id GROUP BY pro_name";
$sth = $dbh->prepare($sql);
$sth->execute();
$sth->bind_columns( undef, \$pro_id,\$pro_name,\$city,\$province,\$type);
while( $sth->fetch() ) {
&province;
&owner_type;
print "<INPUT TYPE=\"CHECKBOX\" NAME=\"company\" VALUE=\"$pro_id\">
$pro_name, $city, $province_name, $type_name<br>\n";
}
$sth->finish();
Could someone help me with this and the proper syntax please.
Thank you.
---------------------------------------------------------------------
Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
posting. To request this thread, e-mail mysql-thread6282@lists.mysql.com
To unsubscribe, send a message to the address shown in the
List-Unsubscribe header of this message. If you cannot see it,
e-mail mysql-unsubscribe@lists.mysql.com instead.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic