请问我执行如下语句报错
select ID from tbxxx where ID in(1,2)但是执行select ID from tbxxx where ID in(1)不会报错执行select ID,title from tbxxx where ID in(1,2)--加了个显示字段列,也不报错请问怎么回事,如何解决。
数据库是oracle 10g
ID作为主键。

解决方案 »

  1.   

    select ID from tbxxx where ID in('1','2')试试
      

  2.   

    同样报错,问题关键
    select id---只提取ID列时 不能用in(,,) 多个条件
    不知道什么原因
      

  3.   

    在10g里面也没有啥问题:
    db2inst2@HASL>select * from v$version;BANNER
    ----------------------------------------------------------------
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    PL/SQL Release 10.2.0.1.0 - Production
    CORE    10.2.0.1.0      Production
    TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
    NLSRTL Version 10.2.0.1.0 - Productiondb2inst2@HASL>create table test (
      2  id number,
      3  title varchar2(20));表已创建。db2inst2@HASL>insert into test values(1, 'test1');已创建 1 行。db2inst2@HASL>insert into test values(2, 'test2');已创建 1 行。db2inst2@HASL>insert into test values(3, 'test3');已创建 1 行。db2inst2@HASL>commit;提交完成。db2inst2@HASL>select * from test;        ID TITLE
    ---------- --------------------
             1 test1
             2 test2
             3 test3db2inst2@HASL>alter table test
      2  add constraint pk_test_1 primary key (id);表已更改。db2inst2@HASL>select id from test where id in (1, 2);        ID
    ----------
             1
             2db2inst2@HASL>