CREATE TABLE `ecs_comment` (
  `comment_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `comment_type` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `id_value` mediumint(8) unsigned NOT NULL DEFAULT '0',
  `email` varchar(60) NOT NULL DEFAULT '',
  `user_name` varchar(60) NOT NULL DEFAULT '',
  `content` text NOT NULL,
  `comment_rank` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `add_time` int(10) unsigned NOT NULL DEFAULT '0',
  `ip_address` varchar(15) NOT NULL DEFAULT '',
  `status` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `parent_id` int(10) unsigned NOT NULL DEFAULT '0',
  `user_id` int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`comment_id`),
  KEY `parent_id` (`parent_id`),
  KEY `id_value` (`id_value`)
) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8
SELECT * FROM `ecshop7`.`ecs_comment` WHERE parent_id = 0   //能查出数据SELECT * FROM `ecshop7`.`ecs_comment` WHERE parent_id = 0  order by comment_id  asc ////注意:不能查出数据
SELECT * FROM `ecshop7`.`ecs_comment` WHERE parent_id = 0   ORDER BY add_time DESC  LIMIT 0, 15 ////注意:不能查出数据
SELECT * FROM `ecshop7`.`ecs_comment` WHERE parent_id = 0   ORDER BY id_value DESC  LIMIT 0, 15 ////注意:不能查出数据
下面的两条sql语句没错,为什么查不出数据?

解决方案 »

  1.   

    能否提供一部分 insert 数据以供测试?
      

  2.   


    INSERT INTO `ecs_comment` VALUES (1, 0, 12, '[email protected]', 'ecshop', '很好,我很喜欢', 5, 1242107120, '0.0.0.0', 1, 0, 1);
    INSERT INTO `ecs_comment` VALUES (2, 0, 22, '[email protected]', 'ecshop', '这个我不是很适合我', 5, 1242107295, '0.0.0.0', 0, 0, 1);
    INSERT INTO `ecs_comment` VALUES (3, 0, 24, '[email protected]', '', 'fff f f fd', 1, 1259758054, '1.0.0.2', 0, 0, 0);
    INSERT INTO `ecs_comment` VALUES (4, 0, 24, '[email protected]', '', 'langhialng', 1, 1259758118, '1.0.0.2', 0, 0, 0);谢谢~
      

  3.   

    估计是索引文件坏了。analyze table ecs_comment;
    repaire table ecs_comment;试一下。
      

  4.   

    我用你的数据测试没有任何问题。
     show index from ecs_comment;
    看一下mysql> show index from ecs_comment;
    +-------------+------------+-----------+-
    +-------------+----------+--------+------
    | Table       | Non_unique | Key_name  |
    | Cardinality | Sub_part | Packed | Null
    +-------------+------------+-----------+-
    +-------------+----------+--------+------
    | ecs_comment |          0 | PRIMARY   |
    |           4 |     NULL | NULL   |
    | ecs_comment |          1 | parent_id |
    |        NULL |     NULL | NULL   |
    | ecs_comment |          1 | id_value  |
    |        NULL |     NULL | NULL   |
    +-------------+------------+-----------+-
    +-------------+----------+--------+------
    3 rows in set (0.00 sec)mysql>
      

  5.   

    SELECT * FROM `ecshop7`.`ecs_comment` WHERE parent_id=0  order by comment_id  asc留WHERE parent_id=0不要order by comment_id  asc也能查出数据
    留 order by comment_id  asc不要WHERE parent_id=0也能查出数据...两个条件就不能一起有,继续郁闷中...
      

  6.   

    你执行的语句,在Order By前面的会不会有什么特殊字符?
      

  7.   

    然后,Mysql参数,sort buffer之类的重新设置一下,但这方面不是最懂