gnos

左连接语句,left outer join

右连接语句,right outer join

内连接语句,inner join

下面举个例子说明。

建立一个student和clazz表

clazz                                                      

id    name

1       一班

2       二班

3        三班

student           

id     name      clazz_id

1       小明            2

2       小红            3

3        小张

内连接查询:select* from student inner join clazz on clazz.id=student.clazz_id;

查询结果,两个表相同条件的的部分显示出来。

 

左连接查询:select* from student left  outer  join clazz

 on clazz.id=student.clazz_id;

student表中内容全部显示,clazz表显示符合的条件,clazz中没有的地方显示为null。

查询结果

 

 

 

右连接查询:select* from student right outer  join clazz 

on clazz.id=student.clazz_id;

clazz表中内容全部显示,student表显示符合的条件,student中没有的地方显示为null。

查询结果

 

 

分类:

技术点:

相关文章:

  • 2021-08-17
  • 2021-11-20
  • 2021-08-23
  • 2021-12-25
  • 2022-02-08
  • 2021-11-20
猜你喜欢
  • 2021-08-17
  • 2021-08-06
  • 2021-06-20
  • 2021-11-08
  • 2022-12-23
  • 2021-08-27
  • 2021-11-15
相关资源
相似解决方案