原sql语句select a1.name,a1.age from a1 where a1.id='123456'
union all
select b1.name,b1.age from b1 where b1.id='123456'
union all
select c1.name,c1.age from c1 where c1.id='123456'
需要的sql语句
怎样定义一下 userid='123456'select a1.name,a1.age from a1 where a1.id=userid
union all
select b1.name,b1.age from b1 where b1.id=userid
union all
select c1.name,c1.age from c1 where c1.id=userid怎么定义一个变量???
union all
select b1.name,b1.age from b1 where b1.id='123456'
union all
select c1.name,c1.age from c1 where c1.id='123456'
需要的sql语句
怎样定义一下 userid='123456'select a1.name,a1.age from a1 where a1.id=userid
union all
select b1.name,b1.age from b1 where b1.id=userid
union all
select c1.name,c1.age from c1 where c1.id=userid怎么定义一个变量???
var uerid number
exec :userid:=123456;select a1.name,a1.age from a1 where a1.id=:userid
union all
select b1.name,b1.age from b1 where b1.id=:userid
union all
select c1.name,c1.age from c1 where c1.id=:userid
userid := 123456;
begin
以下就是你的查询语句……
end;
union all
select b1.name,b1.age from b1 where b1.id=&&userid
union all
select c1.name,c1.age from c1 where c1.id=&&userid运行时会需要输入'&'打头的值,而后面两个‘&&’打头的就可以接受第一个变量的值而不需要重复输入。
from (select a1.id, a1.name, a1.age
from a1
union all
select b1.id, b1.name, b1.age
from b1
union all
select c1.id, c1.name, c1.age from c1)
where id = &userid;
不然这个替代变量能使用?而且刚好写反了吧,应该先两个&&,然后在一个&&使用绑定变量就可以了啊,plsql中使用3#那样的写法,jdbc中使用?