使用join命令。 [英] working of join command.

查看:63
本文介绍了使用join命令。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我们有两个表empolyee和部门有一个公共列deptid。

我们检索数据



1 select *来自员工,employee.deptid = department.id的部门;



2从员工加入部门中选择* employee.deptid = department.id;



所以哪个选项更好,有什么区别

if we having two tables empolyee and department with one common column deptid.
we retrieve data by

1 select * from employee, department where employee.deptid=department.id;

2 select * from employee join department where employee.deptid=department.id;

so which option is better and what is the difference

推荐答案

关于哪个样式的套件可以找到一个非常好的评论此处! [< a href =http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/08/bad-habits-to-kick-using-old-style-joins.aspxtarget =_ blanktitle =新窗口> ^ ]
A very good commentory over which style to suite can be found here![^]


我更喜欢第二个因为以下原因

- 更标准的方式

- 数据库之间更便携

- 可以很容易地修改为不同的joi n种类型,如外部,完整和交叉
I would prefer the second one because of following reasons
- more standard way
- more portable between databases
- can be easily modified to different join types such as outer, full and cross


这篇关于使用join命令。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆