【发布时间】:2014-11-04 11:10:10
【问题描述】:
我目前正在尝试使用 Visual Studio 中的 SQL Server 查询数据库。有问题的数据库包含支付信息,主要通过 OrderID 和 License ID 识别交易及其产生的软件许可证。有时,这些许可证会因滥用而被吊销。
现在,我正在尝试运行一个基于此返回所有客户的查询:
Select
[Order].LastName,
[Order].FirstName,
[Order].CompanyOrganization,
[Order].EmailAddress,
[Order].Country,
[License].LicenseID,
[License].InstanceCount
From [Order], [License]
Where
[License].OrderID = [Order].OrderID
AND [Order].Status = 1
AND not exists (Select LicenseID From [LicenseRevocation])
Order by [License].InstanceCount DESC;
查询没有返回任何结果,我知道这是因为“不存在”部分。但是,我不确定为什么。有人可以弄清楚“EXISTS”是如何工作的以及如何在我的查询中实现它吗?
【问题讨论】:
标签: sql-server tsql not-exists