MySQL联结——实现多表查询

一、内联结

1. 隐式内联结(使用where子句)

select vend_name, prod_name, prod_price
from vendors, products
where vendors.vend_id = products.vend_id;

2. 显式内联结

select vend_name, prod_name, prod_price
from vendors inner join products
on vendors.vend_id = products.vend_id;

二、外联结(可以检索出包含NULL值的行)

// 左外联结会选择左边表中的所有行
select customers.cust_id, orders.order_num
from customers left outer join orders
on customers.cust_id = orders.cust_id;
原文地址:https://www.cnblogs.com/jiajun107/p/12893395.html