在 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 多表查询方法,根据具体的需求和查询条件选择合适的方法进行查询。