51Testing软件测试论坛

标题: 如果有三张表orders(包含order_id、customer_id、product_id)、customers(包含c... [打印本页]

作者: 测试积点老人    时间: 2024-11-7 09:51
标题: 如果有三张表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),查询每个订单的订单号、客户姓名和产品名称。


作者: kallinr    时间: 2024-11-8 09: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
orders.customer_id=customers.customer_id  join orders.product_id = products.product_id
作者: 海海豚    时间: 2024-11-8 10: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;
作者: jingzizx    时间: 2024-11-8 11:32
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
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
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;




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2