oracle 3 多表关联

oracle 获取当前系统时间 sysdate

oracle 设置时间格式 : to_date ('1994/5/5','yyyy/MM/dd')

复制一张新表,表数据和结构一起复制:create table 表名 as select * from 表名

分组查询:

--分组查询,统计各个部门的人数
select count(empno),deptno
from emp group by deptno

模糊查询:

--模糊查询-以指定字符开头
select * from emp
where ename like 'A%'
--第二个自字符是A
select * from emp
where ename like '_A%' 
--任意字符是A
select * from emp
where ename like '%A%'

having 和where的区别

where 先执行筛选数据,having对最后的数据进行筛选

子查询:

多行子查询 : in在子查询里

多表联合查询不能直接查询

会产生笛卡尔积,需要多表间条件连接

1:等值连接

  通过连接条件把所查询的多个表中,都符合的数据查询出来

  例

select e.empno ,e.ename,d.dname
from emp e,dept d
where e.deptno = d.deptno
原文地址:https://www.cnblogs.com/miaomeng/p/8885129.html