还有个问题:
name like '$name%'and company like '%$company%'
在这个逻辑与运算中,如果$name 或者 $company中又一个为空,会出现什么结果?允许吗?
这是我输出我的查询语句的结果:
select cardid,company,name from namecard where name like '于杰%' and company like '%%' and c_telephone like '%' and address like '%%'
在这个查询语句中,我的name值是于杰,其他的都为空,只显示%%,
在sql server 应该显示 null 。不知道是和原因?

解决方案 »

  1.   

    select cardid,company,name from namecard where name like '于杰%' and company like '%%' and c_telephone like '%' and address like '%%';这条语句的作用等同于
    select cardid,company,name from namecard where name like '于杰%';
      

  2.   

    $sql = "select  cardid,company,name from namecard where";将上面的换在下面的看看呢$sql = "SELECT  SQL_BIG_RESULT cardid,company,name from namecard where";
      

  3.   

    我只要用Binary必定会出现这样的错误:
    Lost connection to MySQL server during query
    当我不用的时候运行很好,也不出现上述问题了。
    Binary运算符载传表中去分大小写,难道就因为这个吗?
      

  4.   

    to: shuixin13(犬犬(心帆)) 
    我用了一下,没有变化。对了在查询于句中加如SQL_BIG_RESULT 的作用是什么?什么含义?
    请指教!谢谢!
      

  5.   

    呵呵
    SQL_BIG_RESULT它等同于设置tmp_table_size一般是在发生The table is full错误时使用的,像你这种情况有可能是处理时间过长,或返回的记录集过大???呵呵,我也不能确定,最好将
    max_allowed_packet
    wait_timeout
    interactive_timeout
    均重设一下试试呢你的数据集有多大呀
      

  6.   

    很小,只有10条记录。我不知到为什么加上Binary后就出现上述错误,我用的室模糊查询,Binary可是更好的实现模糊查询。他去分大小写,难道是这里除了问题。
      

  7.   

    你用MySQL-Front执行一下你的SQL语句,
    看看会不会出问题呢,我也是这样做的,