是否可以在三个选择语句之间创建多个联合?



我想在三个选择语句之间创建两个联合运算符,以便能够对尝试在oracle apex中登录我的数据库应用程序的用户进行身份验证。 是否可能,如果是,正确的方法是什么?

select 'USER'
from customers
where upper(cid) = upper(:p_username) and c_pass = :p_password
UNION 
select 'employee'
from employees
where upper(e_un) = upper(:p_username) and e_pass = :p_password;
UNION 
select 'manager'
from employees 
where upper(e_un) = upper(:p_username) and e_pass = :p_password and e_type='MANAGER';

总之,是的,这是可能的。

您或多或少走在正确的轨道上,尽管我会使用区分大小写的用户名和密码比较,并使用union all而不是union以获得更好的性能。

最新更新