用左外连接,指查询出来的是在右表中没有对应左表中的记录以及符合条件(c.id=o.customer_id)的数据,比如:
customers为左表,orders为右表
select c.id,o.customer_id,c.name,o.id order_id,order_number from customers c left outer join orders o on c.id=o.customer_id
2、右外连接:
正好和左外连接相反,查询出来的结果是在左表中没有对应的项和以及符合条件(c.id=o.customer_id)的数据.
左连接select * from table1 as a left join table2 as b on a.id = b.id右连接select * from table1 as a right join table2 as b on a.id = b.id
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)