【发布时间】:2014-03-15 07:41:57
【问题描述】:
我在 SQL Server 中的查询遇到了一个奇怪的行为
我有两个表 PrepaidTransactions 和 BillingData,我正在执行以下查询
Select *
from PrepaidTransactions
where customer_Id in
(Select customer_Id
from BillingData
where CommunityId = 10004)
列customer_Id 不属于表BillingData。查询正在执行并返回 PrepaidTransactions 表中的所有记录,而不是显示错误
但是当我运行以下查询时
Select customer_Id
from BillingData
where CommunityId = 10004
显示错误
列名“customer_Id”无效。
谁能告诉我为什么第一个查询没有显示任何错误?
【问题讨论】:
-
第一个查询运行是因为
customer_Id明确解析为PrepaidTransactions.customer_Id -
我很确定结果集不是您所期望的
-
@MoslemBenDhaou ,是的,结果集不是我所期望的。
-
@MartinSmith,是的,它可能是重复的,但是在发布这个问题之前,我检查并找不到它。
标签: sql sql-server execution query-expressions