`
Jatula
  • 浏览: 276709 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

多表查询查漏补缺

 
阅读更多
/*--左外连结 左表的全部记录(部门表中的所有记录:demp)-- */
/*--方式2--*/      
select e.ename,d.dname
       from dept d , emp e
       where d.deptno = e.deptno(+)
-------后面(+)的意思不清楚;

/*-- any 比较返回值中的任何一个,其中一个满足,则返回true --*/
select * from emp e
where e.sal < any(select sal from emp where deptno=2)

/*--记录总数 --*/
select count(*) from emp
select count(memo) from emp   /*--统计该栏非空记录 --*/
select count(distinct(sex)) from emp    /*--去掉重复记录 --*/

/*-- group by having --*/
select e.deptno,avg(e.sal)
from emp e
group by e.deptno
having avg(e.sal) > 4500

获取系统时间:select now();  
日期转换:select date_format(now(), '%Y-%m-%d  %H:%i:%s') 

MySQL

select * from dept order by deptno desc limit 3, 2;  
 
在java程序中一般设:  
3---------->每页显示的个数 * 你所选择的第几页  + 1  
2---------->每页显示的个数 
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics