多表连接查询

  • 内连接查询
    连接结果默认是迪卡尔积, 根据连接条件连接满足条件的记录
  1. select t1.feild,...t2.field,... from
  2. tableName1 as t1 inner join tableName2 as t2 on condition;
  • 左外连接查询
    连接结果以左表为准, 如果在右表中没有没有满足条件的记录,则左表记录后连接 NULL 值
  1. select t1.feild,...t2.field,... from
  2. tableName1 as t1 left join tableName2 as t2 on condition;
  • 右外连接查询
    连接结果以右表为准, 如果在左表中没有没有满足条件的记录,则右表记录后连接 NULL 值
    **可以通过
  1. select t1.feild,...t2.field,... from
  2. tableName1 as t1 right join tableName2 as t2 on condition;

两表以上多表连接查询

  1. select t1.feild,...t2.field,t3.field,... from tableName1 as t1
  2. xxx join tableName2 as t2 on condition
  3. xxx join tableName3 as t3 on condition....,....;