首頁  >  文章  >  資料庫  >  mysql聯合查詢怎麼定義

mysql聯合查詢怎麼定義

WBOY
WBOY轉載
2023-05-29 18:10:06543瀏覽

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刪除