文章詳情頁
mysql 使用 join 還是 "," 進行多表查詢???
瀏覽:114日期:2022-06-16 08:14:50
問題描述
問題解答
回答1:其實select s.sid , s.name , a.score from student as s , achievement as a where s.sid = a.sid;等同于select s.sid , s.name , a.score from student as s inner join achievement as a on s.sid = a.sid;通過explain sql 查看查詢情況
回答2:left join是左鏈接,使用逗號鏈表查詢是內(nèi)連接,是有一定的區(qū)別的,左鏈接是用左邊的表作為主表來查詢的,當右表沒有數(shù)據(jù)的時候,還是有會查出來左表記錄的,而內(nèi)連接如果右表沒有數(shù)據(jù),那么也就查不出來左表這條數(shù)據(jù)了。
回答3:join的效率低 下面的高
排行榜

熱門標簽