【发布时间】:2018-11-05 14:32:01
【问题描述】:
Microsoft Sql Server 2017,Northwind 数据库。
大家好,我还在尝试在sql server中做这些问题,但是我堆叠了,我不知道该怎么做。请给我一些提示,如何咬它:P
select *
from
(select companyname, products.productid, productname,[Order Details].OrderID
from [order details], orders, customers, products
where [order details].orderid=orders.orderid AND
orders.customerid=customers.customerid AND
[order details].productid=products.productid) c1
inner join
(select companyname, products.productid, productname, [Order Details].OrderID
from [order details], orders, customers, products
where [order details].orderid=orders.orderid AND
orders.customerid=customers.customerid AND
[order details].productid=products.productid AND
Customers.Country='Brazil') c2
on c1.productId=c2.productId and c1.productname=c2.productname
【问题讨论】:
-
您应该从学习 ANSI-92 样式连接开始。它们已经上市超过 25 年了。 sqlblog.org/2009/10/08/bad-habits-to-kick-using-old-style-joins 对于手头的问题,我不太确定您要完成什么。
-
好的,我会阅读链接 :) 我必须显示订购同一组产品的客户,就像来自巴西的客户一样,所以我必须以某种方式比较两个选择并显示公司名称.
-
我建议也使用一些别名。 :)
标签: sql sql-server northwind