根据一个变量的值 来控制sql的执行

第一种方式(union拼接)

select c_fundcode from table2 where  变量 = 1

union

select c_fundcode from table2 where  变量 = 2  and 可加各种条件(in, like , =)


第二种方式(等于本身的方式)

select * from table where c_fundcode = decode(变量,1,2222,c_fundcode)


猜你喜欢

转载自blog.csdn.net/qq_29495223/article/details/80433155