select * from table where name = 'sdfsdf\&''';在单引括号内可以用两个单引号来代替一个,如
SELECT '''' FROM DUAL;'
-
'

解决方案 »

  1.   

    特殊的字符要通过相关的符号转义。如' escape等等
      

  2.   

    为什么都不肯说详细一点啊,单引号可以用两个单引号来搞定,那斜杠呢\,怎么办,还有&符号呢
      

  3.   

    斜杠\,不就是select '\','&' from table
    还有,楼主你的说的处理指的是什么?sql分析吗?
      

  4.   

    看来是我没说清楚,我的意思说遇到\,'这种特殊字符应该怎么办?比如这句select * from table where name = 'sdfsdf\&'',这样直接写肯定不行的,像在MYSQL里面就是直接在特殊字符前面加\就可以了,就变成select * from table where name = 'sdfsdf\\\&\''。这样就Ok了,可是在ORAcle里面,这样不行啊,怎么样才能实现正常的查询呢
      

  5.   

    select * from table where name = '%' 
    select * from table where name ='&'
    select * from table where name ='\'
    都是可以的,但
    select * from table where name = 'asdf&%'就不可以
      

  6.   

    我们可以试试:
    create table table1(col1 varchar2(10));
    insert into table1 values('\');
    insert into table1 values('&');
    insert into table1 values('%');
    insert into table1 values('sdfsdf\&''');
    commit;select * from table1;COL1
    ----------
    \
    &
    %
    sdfsdf\&'SELECT * FROM table1 WHERE col1 LIKE '%\%';COL1
    ----------
    \
    sdfsdf\&'
      

  7.   

    呵呵.关于&这个特殊字符的用法的确很特殊.
    可以考虑用like
    相关资料说可以用q来转义,但对&无效。