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;
posted @ 2020-05-15 10:25  Java程序员的进阶之路  阅读(173)  评论(0编辑  收藏  举报