比如 字符串: A'SQL:select * from table1 where id='A''这样就会报错。如何实现 查询条件 为id 等与 A'

解决方案 »

  1.   

    用转义字符例如:select  p_name, p_id from products
    where p_name like '/%scott' escape '/';
    select * from table1 where id='A/'' escape '/';
      

  2.   

    oracle10g,用q'[]'或q'{}'等select q'[A']' from dual;
    select q'{A'}' from dual;
    select q'!A'!' from dual;oracle9i以前,则用''代替一个',如
    select 'A''' from dual;
      

  3.   

    也就是说
    select * from table1 where id='A'||'''' 
    或者:
    select * from table1 where id='A'|| chr(39)
      

  4.   

    如果你想具体的了解转义字符的使用 可以自己上GOOGLE去查询,信息很多的:)
      

  5.   

    select * from table1 where id='A'''
      

  6.   


    create table tt(name varchar(10))
    insert into tt select 'a' from dual
    insert into tt select 'a''' from dualselect * from tt
    where name=q'[a']' 
    ---
    name
    a'
    -----
      

  7.   

    select q'[a']',q'{a'}',q'(a')',q'"a'"' ,q'!a'!' from dual