作者bernachom (Terry)
看板Database
标题[SQL ] join观念询问..
时间Sun Jun 22 18:37:56 2014
请教一下
我有看到这个例子
(一) select * from table1 cross join table 2 where table1.id = table2.fd_id
(二) select * from table1 join table2 on table1.id =table2.fd_id
这两个结果是一样的
但是(二)这个效能会比较好吗??
cross join 不是只差在把where换成on这样子而已呢??
还麻烦前辈指教一下,谢谢了
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 59.120.19.22
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/Database/M.1403433479.A.090.html
1F:推 scpisces:我认为是 06/22 22:19
2F:→ scpisces:(一)假设table1、table2各10笔资料,使用cross join後 06/22 22:20
3F:→ scpisces:会变100笔资料,再根据where条件捞出所要的资料 06/22 22:20
4F:→ scpisces:(二)table1、table2有相同的资料才会出来 06/22 22:20
5F:→ scpisces:所以效能上来说,是(二)比较好 06/22 22:21
6F:→ scpisces:如有错请纠正 06/22 22:21