sql三表查询

情景:

student  id    stname    sex

score   scoreid  stname  birth

course id    coursename  age

简单说明  a,b ,c 三表a.name=b.name a.id=c.id

现在要查 id ,name ,course 

有两种方法:

select a.id,b.name,c. coursename from student a,score b,course c where a.name=b.name and a.id=c.courseid; 
select a.id,b.name,c. coursename from student a inner join score b on a.name=b.name inner join course c on a.id=c.courseid;

猜你喜欢

转载自www.cnblogs.com/SunshineKimi/p/10738895.html