首页  >  文章  >  数据库  >  mysql联合查询怎么定义

mysql联合查询怎么定义

WBOY
WBOY转载
2023-05-29 18:10:06547浏览

1、又称连接查询,连接多个表中的数据,获得结果集。当一个表不能满足查询结果时,需要使用联合查询。

2、前提,联合表之间必须有逻辑相关性。

实例

-- 示例:
select orders.order_id, orders.amt, customer.cust_name, customer.tel_no
from orders, customer
where orders.cust_id = customer.cust_id;
 
-- 起别名
select a.order_id, a.amt, b.cust_name, b.tel_no
from orders a, customer b
where a.cust_id = b.cust_id;

以上是mysql联合查询怎么定义的详细内容。更多信息请关注PHP中文网其他相关文章!

声明:
本文转载于:yisu.com。如有侵权,请联系admin@php.cn删除