id 是唯一的,MySQL 做查询,你的 id 字段是主键不是,有没有建立索引,id 是主键是自动增加 。 顺序 1,2,3,4,5 ......不是主键不是自动增加 。顺序 1,200,38 ......如果 id 是主键并且自动增加,对 dmlx 也做索引,然后再查询。 $str_sql="select * from dddd where id='".$id."'" and dmlx=1 ;

解决方案 »

  1.   

    id是主键,并且是自动增加,dmlx是一种类型,区分作用的。
      

  2.   

    最好把能精确定位的条件放在前面
    例如$s = "select * from abc where a='".$a."' and b like '%".$b."%'"
    肯定比
    $s = "select * from abc where b like '%".$b."%'  and  a='".$a."'"
      

  3.   

    这样吧,id肯定是最精确的,dmlx不精确的,我想先通过dmlx,然后再id,不知道是不是多此一举了。