新手?
$name=登录名
$sql='select title from tbl_name where adminname like "%'.$name.'%"';

解决方案 »

  1.   

    我试了一下。是可以显示出来。但我用user01登录后,它会显示三个
    abc
    dir
    three
      

  2.   

    $sql='select title from tbl_name where adminname REGEXP "(^|\|)$name(\||$)"';
      

  3.   

    SQL: select * from tab where admin REGEXP '(^|\|)user01(\||$)'
    Error: Got error 'empty (sub)expression' from regexp
    Errno.: 1139上面提示什么意思
      

  4.   

    未发现的 函数或表达式SQL语句支持正则吗???
    我试了一下。是可以显示出来。但我用user01登录后,它会显示三个
    abc
    dir
    three如果出现这种情况,可能是你用了GROUP BY的缘故,如果你没用的话,请将处理代码贴出来。。
      

  5.   

    试试下面的
    select * from ib_article where title REGEXP '[^\|]user01[\|$]';
      

  6.   

    SQL语句支持正则吗???
    当然支持,看看手册就知道了 =)
      

  7.   

    处理代码$query=mysql_query("select * from tab where admin REGEXP '(^|\|)user01(\||$)'");错误提示
    SQL: select * from tab where admin REGEXP '(^|\|)user01(\||$)'
    Error: Got error 'empty (sub)expression' from regexp
      

  8.   

    to ice_berg16(寻梦的稻草人)select * from ib_article where title REGEXP '[^\|]user01[\|$]';上面这句没有出错信息,但没有任何显示。
      

  9.   

    -_-! 
    再试,手头没环境,没法测试select * from tab where admin REGEXP '(^|\\|)user01(\\||$)';
      

  10.   

    to ice_berg16(寻梦的稻草人)错误提示
    SQL: select * from tab where admin REGEXP '(^|\|)user01(\||$)'Error: Got error 'empty (sub)expression' from regexp
      

  11.   

    to ice_berg16(寻梦的稻草人)但是错误提示的确是SQL: select * from tab where admin REGEXP '(^|\|)user01(\||$)'Error: Got error 'empty (sub)expression' from regexp
      

  12.   

    我用的是这个,楼主看看!set rs=server.createobject("adodb.recordset")
    sql="select * from tbl_name "
    rs.open sql,conn,1,3
    while not rs.eof
    id=rs("id")
    gly=rs("title")
    nn=session("adminname")if instr("|"&gly&"|","|"&nn&"|")>0 then用instr()来判断用户是否是该栏目的超级用户
      

  13.   

    to liubi(liubi) :  请检查你的程序, 肯定不应该是你给出的错误,你的sql语句明显还是原来那个,
      你可能忘记改了. 
      如果是在浏览器中运行请先清缓存再试
      

  14.   

    to ice_berg16(寻梦的稻草人) $query=$db->query("select * from tab where superadmin REGEXP '(^|\\|)user01(\\||$)'");SQL: select * from tab where superadmin REGEXP '(^|\|)user01(\||$)'
    Error: Got error 'empty (sub)expression' from regexp
    Errno.: 1139
      

  15.   

    $query=$db->query("select * from tab where superadmin REGEXP '(^|\\\\|)user01(\\\\||$)'");
      

  16.   

    SELECT  * 
    FROM  `power` 
    WHERE adminname
    REGEXP  "^user01[\|]|[\|]user01[\|]|[\|]user01$"楼主改下表名和字段名
      

  17.   

    谢谢各位    ice_berg16(寻梦的稻草人)  的答案能得到全部正确的结果    hzsasheng(等风的旗)       的答案能得到部分正确的结果(还要考虑到当两边都没有"|"时的情形)
      

  18.   

    SELECT  * 
    FROM power
    WHERE adminname
    REGEXP  '(^|\\\\|)user01(\\\\||$)'为什么我这句在PHPMYADMIN直接执行会有错误??MySQL 返回:
    Got error 'empty (sub)expression' from regexp