Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter foiledagain

    (@foiledagain)

    Thanks, andy!

    Thread Starter foiledagain

    (@foiledagain)

    According to mysql --version, I’m using mysql Ver 14.12 Distrib 5.0.22, for pc-linux-gnu (i486) using readline 5.1

    Thread Starter foiledagain

    (@foiledagain)

    A little more investigation—MySQL seems to think that 0 and ‘0’ are the same value:

    mysql> select 0=0;
    +-----+
    | 0=0 |
    +-----+
    |   1 |
    +-----+
    1 row in set (0.00 sec)
    
    mysql> select 0='0';
    +-------+
    | 0='0' |
    +-------+
    |     1 |
    +-------+
    1 row in set (0.00 sec)
    
    mysql> select 0=1;
    +-----+
    | 0=1 |
    +-----+
    |   0 |
    +-----+
    1 row in set (0.00 sec)

    It also thinks that there are only three possible values for comment_approved: 0, 1, and spam.

    mysql> select distinct(comment_approved) from wp_comments;
    +------------------+
    | comment_approved |
    +------------------+
    | 0                |
    | 1                |
    | spam             |
    +------------------+
    3 rows in set (0.00 sec)

    How many do I have of each?

    mysql> select count(comment_approved), comment_approved from wp_comments group by comment_approved ;
    +-------------------------+------------------+
    | count(comment_approved) | comment_approved |
    +-------------------------+------------------+
    |                       1 | 0                |
    |                  179591 | 1                |
    |                     452 | spam             |
    +-------------------------+------------------+
    3 rows in set (0.41 sec)
    mysql> select count(*) from wp_comments where comment_approved = 'spam';
    +----------+
    | count(*) |
    +----------+
    |      452 |
    +----------+
    1 row in set (0.00 sec)
    mysql> select count(*) from wp_comments where comment_approved ='0';
    +----------+
    | count(*) |
    +----------+
    |        1 |
    +----------+
    1 row in set (0.02 sec)
    mysql> select count(*) from wp_comments where comment_approved = 0;
    +----------+
    | count(*) |
    +----------+
    |      453 |
    +----------+
    1 row in set (0.16 sec)

    I don’t get it. Why is 0 equal to ‘0’, and why does ‘spam’ also appear to be equal to 0?

Viewing 3 replies - 1 through 3 (of 3 total)