是“=”好,还是join好

yun198183 2003-10-14 05:17:00
如题,比较困惑
...全文
164 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
lufree 2003-10-15
  • 打赏
  • 举报
回复
xx
playyuer 2003-10-14
  • 打赏
  • 举报
回复
*= 如果多表链接,where 子句 and 条件的顺序可能会影响查询结果!
可能会产生歧义,尽量用join
孟子E章 2003-10-14
  • 打赏
  • 举报
回复
good~:)
zarge 2003-10-14
  • 打赏
  • 举报
回复
=与inner join是一样的,但=*、*=与right join和left join是不一样,可能会产生歧义,尽量用join
friendliu 2003-10-14
  • 打赏
  • 举报
回复
JOIN比较好呀。。可以详细的设定条件
LEFT JOIN
RIGHT JOIN
FULL JOIN
参考SQL联机帮助
Wally_wu 2003-10-14
  • 打赏
  • 举报
回复
看请况,如果表的字段太多的话,用join好
pengdali 2003-10-14
  • 打赏
  • 举报
回复
是,=* 和 *=也是= 的左右联结,如果你要标准就用join好了,不过效率是一样的。
rottenapple 2003-10-14
  • 打赏
  • 举报
回复
*=
=*
=
也可以实现join相应的
不过编译后是一样的
yun198183 2003-10-14
  • 打赏
  • 举报
回复
我看书,join是标准建议
playyuer 2003-10-14
  • 打赏
  • 举报
回复
join SQL92标准建议!where 子句 and 条件的顺序不会影响查询结果

= 如果多表链接,where 子句 and 条件的顺序可能会影响查询结果!
愉快的登山者 2003-10-14
  • 打赏
  • 举报
回复
join更详细,如:

左连接,
select * from table1 a left join table2 b on a.n1=b.n1
显示结果以左表table1为主,凡是右表able2中的记录没有与左表table1中的记录构成连接条件的a.n1=b.n1 不显示;
相反,右连接,
select * from table1 a right join table2 b on a.n1=b.n1
显示结果以右表able2为主,凡是左表table1中的记录没有与右表able2中的记录构成连接条件的a.n1=b.n1 不显示;

create table #t(id int, a char)
insert #t values (1, 'a')
insert #t values (2, 'b')
create table #t1(id int, a char)
insert #t1 values (1, 'A')
insert #t1 values (3, 'C')

select * from #t inner join #t1 on #t.id = #t1.id
id a id a
----------- ---- ----------- ----
1 a 1 A

(1 row(s) affected)
select * from #t left join #t1 on #t.id = #t1.id
id a id a
----------- ---- ----------- ----
1 a 1 A
2 b NULL NULL

(2 row(s) affected)
select * from #t right join #t1 on #t.id = #t1.id
id a id a
----------- ---- ----------- ----
1 a 1 A
NULL NULL 3 C

(2 row(s) affected)
select * from #t full join #t1 on #t.id = #t1.id
id a id a
----------- ---- ----------- ----
1 a 1 A
NULL NULL 3 C
2 b NULL NULL

(3 row(s) affected)
txlicenhe 2003-10-14
  • 打赏
  • 举报
回复
基本一样的,但有些时候"="达不到要求。
pengdali 2003-10-14
  • 打赏
  • 举报
回复
一样,只是写法不同,sqlserver预编译后是一模一样的。

你写下面代码:

select * from pubs..jobs a join pubs..jobs b on a.job_id=b.job_id

select * from pubs..jobs a,pubs..jobs b where a.job_id=b.job_id

到查询分析器,按下crtl+L看下面的执行计划,它们是一样的。
yujohny 2003-10-14
  • 打赏
  • 举报
回复
=跟join怎么比较????
什么时候能比较的???

34,874

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧