今天 学习了union函数,可以把两个不同的表,或者是同一个表,(但是对应的字段必须一致(要联合起来的字段))
如一:同一个表
create table USERS
(
id NUMBER,
uname VARCHAR2(10),
upwd VARCHAR2(10),
sex VARCHAR2(10)
)
select t1.uname from USERS t1 where t1.uname like '%翟%'
union select t1.uname from USERS t1 where t1.uname like '%李%'
如二:两个不同的表
表一:
create table USERS
(
id NUMBER,
uname VARCHAR2(10),
upwd VARCHAR2(10),
sex VARCHAR2(10)
)
表二:
create table TESTCONNECTIONORACLE
(
id NUMBER,
uname VARCHAR2(10),
upwd VARCHAR2(10),
sex VARCHAR2(10)
)
select t1.uname from USERS t1 where t1.uname like '%翟%'
union select t.uname from TESTCONNECTIONORACLE t
、