在 MySQL 中,進行多表查詢有以下幾種方法:
SELECT Orders.OrderID, Customers.CustomerName
FROM Orders
INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;
SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
LEFT JOIN Orders ON Customers.CustomerID = Orders.CustomerID;
SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
RIGHT JOIN Orders ON Customers.CustomerID = Orders.CustomerID;
SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
CROSS JOIN Orders;
SELECT CustomerName FROM Customers
UNION
SELECT ProductName FROM Products;
SELECT CustomerName, OrderID
FROM Customers
WHERE CustomerID IN (SELECT CustomerID FROM Orders);
以上是一些常用的 MySQL 多表查詢方法,根據具體的需求和查詢條件選擇合適的方法進行查詢。