把多个select的结果组合到一起
select deptno,ename
from emp
union
select deptno,dname
from dept
把多个select的结果组合到一起,保留重复项
select *
from emp
where sal<1000
union all
select *
from emp
where sal<1500
把多个select的结果组合到一起,并排序
select *
from emp
where sal<1000
union all
select *
from emp
where sal<1500
order by sal desc
修改奖金为0的列,改成100
update emp
set comm=100
where comm=0
修改奖金为空的列,改成100
update emp
set comm=100
where comm is null
修改ALLEN的奖金,改成100
update emp
set comm=100
where ename='allen'
修改ALLEN的奖金,改成原来的2倍
update emp
set comm=comm*2
where ename='allen'
修改emp表中job列长度为100
修改emp表ALLEN的job为部门名称+工作名称。
update emp e
join dept d on e.DEPTNO=d.DEPTNO
set job=concat(d.DNAME,e.JOB)
where e.ENAME='allen'
显示计算出emp中各员工的工龄
select *,year(now())-year(hiredate)
from emp
给emp表ALLEN的雇佣日期推后一个月
update emp
set hiredate=adddate(hiredate,interval 1 month)
where ename='allen'
给emp表ALLEN的雇佣日期推后一天
update emp
set hiredate=adddate(hiredate,interval 1 day)
where ename='allen'
给emp表ALLEN的雇佣日期推后一年
update emp
set hiredate=adddate(hiredate,interval 1 year)
where ename='allen'