现在有4张表,要求分别显示:
现在4张表中的id都是一样的,如何在开头写例如:id1=123,然后下面的条件中id=id1,这样就不用写入4遍,只需要将id1=123修改下就可以运行了。select * from a where id='';
select * from b where id='';
select * from c where id='';
select * from d where id='';

解决方案 »

  1.   

    定义变量v_id
    select * from a where id=v_id;
    select * from b where id=v_id;
    select * from c where id=v_id;
    select * from d where id=v_id;
      

  2.   

    已经搞定了,步骤大致如下:
    select * from a where id='&id';
    select * from b where id='&id';
    select * from c where id='&id';
    select * from d where id='&id';
    点击执行,弹出一个框,把你要输入的id号输入,然后执行,就OK了,会显示出4张要查询表的结果。
      

  3.   

    你要写PL/SQL?
    PL/SQL 中select 后面必须要连接有into 如 select ename into v_name where empid=111;
    所以在pl/sql中 像你那样的写法是有问题的。如果是一般的SQL语句,可以这样,&ID,变量如果是字符串类型的就加引号 '&NAME'
    SELECT * FROM emp WHERE empno=&ID;
    SELECT * FROM emp1 WHERE empno=&ID;
    SELECT * FROM emp2 WHERE empno=&ID;  
    --运行时会要求你输入ID的值