John,

> I tried using LIKE \"%published%\" and even LIKE \"%ub%\"  The
> results are the same as when I attempt = \"published\"
>
> Something in the query processing works differently when = is used in
> the WHERE.
>
> I can see no explanation in the data stored in the table.

The important thing is what MySQL 'sees'!

You've already started testing your premise <<<ASSUMING all records are
either "input" or "published">>> One suggestion would be to use the
MySQL client for investigations, then if you don't get the same result
from PHP you have a hint of where the problem lies.

First off, using the MySQL client/outside PHP, try repeating the
experiment, by 'getting the numbers' FOR the expected two values:

SELECT record_date, COUNT(*) AS number_of_letters
  FROM -*-table_name-*-
  WHERE status = "published";

and

SELECT record_date, COUNT(*) AS number_of_letters
  FROM -*-table_name-*-
  WHERE status = "input";

Then check to see what MySQL thinks is in the table apart from those two
values:

SELECT record_date, COUNT(*) AS number_of_letters
  FROM -*-table_name-*-
  WHERE ( status <> "input" ) AND ( status <> "published" );

Of course, the above will list the actual row data. If you want to see
how many different values appear in the status column the following will
give you the various different values and the number of rows of each:

SELECT status, COUNT(status) AS number_of_letters
  FROM -*-table_name-*-
  GROUP BY status;

How do those numbers stack up?

Regards,
=dn


> > > I have a table with approximately 600 rows. Two of the fields are
> > > "record_date" and "status"  Every record has an entry in the
> > > "record_date" in 0000-00-00 format.  The "status" is either
> > "input"
> > > or "published"

> > > So, here is the puzzle.  These two queries serve up dramatically
> > > different results. The only difference in the query is the WHERE
> > > statement.
> > >
> > > $sql = "SELECT record_date, COUNT(status) AS number_of_letters
> > > FROM $table_name
> > > WHERE status = \"published\"
> > > GROUP BY record_date
> > > ";
> > >
> > >
> > > $sql = "SELECT record_date, COUNT(status) AS number_of_letters
> > > FROM $table_name
> > > WHERE status <> \"input\"
> > > GROUP BY record_date
> > > ";
> > >
> > > The query WHERE status = \"published\" finds 17 rows.
> > >
> > > The query WHERE status <> \"input\" finds 33 rows.
> > >
> > > The 33 row answer is the correct answer. I checked the individual
> > > records and can find no record with an answer other than "input"
> > or
> > > "published" in the status.
> > >
> > > ASSUMING all records are either "input" or "published" and all
> > > records have valid record_date, WHY does <> status give a
> > different
> > > result than = status?


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to