Is there a known issue with MySQL and count(*) ? Whenever i use count(*) in
a SELECT command it returns 0 rows.

Thanks
Robert

Re: MySQL and count(*) by Veszko

Veszko
Fri Jul 09 04:53:03 CDT 2004

I've been using MySQL from almost 4 years, you can imagine how many times I
used "COUNT(*)" ... I don't remember I had any kind of problems with it???
You may need to check the following:

1. Table? empty?
2. The condition in your SELECT query? probably returns nothing
3. Access right? you may have no access rights for the database, usually
"root" user can have all sufficient rights
4. Can you run your query in your MyAdmin program? or in your MySQLFront? or
in any well-known MySQL manager?

Regards,

Veszko

"Pèlerin" <rlafond2@videotron.ca> wrote in message
news:w%jHc.16075$m77.336338@weber.videotron.net...
> Is there a known issue with MySQL and count(*) ? Whenever i use count(*)
in
> a SELECT command it returns 0 rows.
>
> Thanks
> Robert
>
>
>



Re: MySQL and count(*) by Pèlerin

Pèlerin
Fri Jul 09 09:30:23 CDT 2004

Hi Vesko,

When I execute "SELECT * FROM employees" it works fine but when i execute
SELECT count(*) FROM employees" 0 rows are returned instead of the single
row holding the number of records. Connection is through OLEDB.

But since you've been doing it for years i'll take for granted it's
supposed to work ;)

But just in case i am doing something wrong ( i am quite new to .NET ) here
is the piece of code:


OleDbCommand oleDbCommand = GetOleDbCommand("SELECT Count(*) FROM
employee");
if (oleDbCommand != null)
{
try
{
OleDbDataReader myReader = oleDbCommand.ExecuteReader();
if (myReader.Read())
{
recCount = myReader.GetInt32(0);
}
(...)
}
finally
{
(...)
}
)


Take for granted that "GetOleDbCommand" returns a properly initialized
"OleDbCommand" object with an opened connection to the database. recCount =
0

Regards
Robert


"Veszko" <public_2000@hotmail.hu> a écrit dans le message de
news:ORXthpZZEHA.1980@TK2MSFTNGP09.phx.gbl...
> I've been using MySQL from almost 4 years, you can imagine how many times
I
> used "COUNT(*)" ... I don't remember I had any kind of problems with it???
> You may need to check the following:
>
> 1. Table? empty?
> 2. The condition in your SELECT query? probably returns nothing
> 3. Access right? you may have no access rights for the database, usually
> "root" user can have all sufficient rights
> 4. Can you run your query in your MyAdmin program? or in your MySQLFront?
or
> in any well-known MySQL manager?
>
> Regards,
>
> Veszko
>
> "Pèlerin" <rlafond2@videotron.ca> wrote in message
> news:w%jHc.16075$m77.336338@weber.videotron.net...
> > Is there a known issue with MySQL and count(*) ? Whenever i use
count(*)
> in
> > a SELECT command it returns 0 rows.
> >
> > Thanks
> > Robert
> >
> >
> >
>
>



Re: MySQL and count(*) by Hasani

Hasani
Fri Jul 09 13:09:43 CDT 2004

what does oleDbCommand.ExecuteScalar() return?
and what if you do
object value = myReader[0];
what is stored in parameter value?
"Pèlerin" <rlafond2@videotron.ca> wrote in message
news:AUxHc.32749$m77.812568@weber.videotron.net...
> Hi Vesko,
>
> When I execute "SELECT * FROM employees" it works fine but when i
execute
> SELECT count(*) FROM employees" 0 rows are returned instead of the single
> row holding the number of records. Connection is through OLEDB.
>
> But since you've been doing it for years i'll take for granted it's
> supposed to work ;)
>
> But just in case i am doing something wrong ( i am quite new to .NET )
here
> is the piece of code:
>
>
> OleDbCommand oleDbCommand = GetOleDbCommand("SELECT Count(*) FROM
> employee");
> if (oleDbCommand != null)
> {
> try
> {
> OleDbDataReader myReader = oleDbCommand.ExecuteReader();
> if (myReader.Read())
> {
> recCount = myReader.GetInt32(0);
> }
> (...)
> }
> finally
> {
> (...)
> }
> )
>
>
> Take for granted that "GetOleDbCommand" returns a properly initialized
> "OleDbCommand" object with an opened connection to the database. recCount
=
> 0
>
> Regards
> Robert
>
>
> "Veszko" <public_2000@hotmail.hu> a écrit dans le message de
> news:ORXthpZZEHA.1980@TK2MSFTNGP09.phx.gbl...
> > I've been using MySQL from almost 4 years, you can imagine how many
times
> I
> > used "COUNT(*)" ... I don't remember I had any kind of problems with
it???
> > You may need to check the following:
> >
> > 1. Table? empty?
> > 2. The condition in your SELECT query? probably returns nothing
> > 3. Access right? you may have no access rights for the database, usually
> > "root" user can have all sufficient rights
> > 4. Can you run your query in your MyAdmin program? or in your
MySQLFront?
> or
> > in any well-known MySQL manager?
> >
> > Regards,
> >
> > Veszko
> >
> > "Pèlerin" <rlafond2@videotron.ca> wrote in message
> > news:w%jHc.16075$m77.336338@weber.videotron.net...
> > > Is there a known issue with MySQL and count(*) ? Whenever i use
> count(*)
> > in
> > > a SELECT command it returns 0 rows.
> > >
> > > Thanks
> > > Robert
> > >
> > >
> > >
> >
> >
>
>