测试积点老人 发表于 2024-11-7 09:51:45

如果有三张表orders(包含order_id、customer_id、product_id)、customers(包含c...

如果有三张表orders(包含order_id、customer_id、product_id)、customers(包含customer_id、customer_name)和products(包含product_id、product_name),查询每个订单的订单号、客户姓名和产品名称。
**** Hidden Message *****

kallinr 发表于 2024-11-8 09:19:19

SELECT o.order_id, c.customer_name, p.product_name
FROM orders o
JOIN customers c ON o.customer_id = c.customer_id
JOIN products p ON o.product_id = p.product_id;

oliver.tang 发表于 2024-11-8 09:21:38

orders.customer_id=customers.customer_idjoin orders.product_id = products.product_id

海海豚 发表于 2024-11-8 10:54:46

SELECT o.order_id, c.customer_name, p.product_name
FROM orders o
JOIN customers c ON o.customer_id = c.customer_id
JOIN products p ON o.product_id = p.product_id;

jingzizx 发表于 2024-11-8 11:32:04

SELECT o.order_id, c.customer_name, p.product_name
FROM orders o
JOIN customers c ON o.customer_id = c.customer_id
JOIN products p ON o.product_id = p.product_id;

你好浮戈 发表于 2024-11-8 13:16:59

SELECT o.order_id, c.customer_name, p.product_name
FROM orders o
JOIN customers c ON o.customer_id = c.customer_id
JOIN products p ON o.product_id = p.product_id;

litingting0214 发表于 2024-11-8 13:54:54

SELECT o.order_id, c.customer_name, p.product_name
FROM orders o
JOIN customers c ON o.customer_id = c.customer_id
JOIN products p ON o.product_id = p.product_id;
页: [1]
查看完整版本: 如果有三张表orders(包含order_id、customer_id、product_id)、customers(包含c...