表结构:
student:
--------------------------
sid name sex
1 cxl male
2 yueshu female
....
--------------------------
achievement:
--------------------------
aid sid cid score
1 1 1 80
2 2 2 60
....
--------------------------
join
连接 :
select s.sid , s.name , a.score from student as s left join achievement as a on s.sid = a.sid;
,
连接 :
select s.sid , s.name , a.score from student as s , achievement as a where s.sid = a.sid;
上面两种写法得出的结果都是一样的,不知道哪个性能更好??
有没有 关于sql优化的中文教程网站
?求推荐
其实
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
查看查询情况