当我运行以下查询时,我遇到了以下问题
SELECT ClientSubId,ClientType,ClientStatus,AddressLine1,AddressLine2,
CityName,PostalCode,StateProvinceCode,
ClientFirstName,ClientLastName, BillManagerName
FROM CLIENT
JOIN
CLIENTADDRESS
ON CLIENT.ClientIdent = CLIENTADDRESS.ReferenceIdent
JOIN
CLIENTINDIVIDUAL
ON CLIENT.ClientIdent = CLIENTINDIVIDUAL.ClientIdent
JOIN
CLIENTPRACTICE
ON CLIENT.ClientIdent = CLIENTPRACTICE.ClientIdent
我正在返回与所有字段匹配的所有结果,女巫是正确的,但是当我在末尾应用where子句
WHERE
CLIENT.ClientIdSubId = '48079'
我没有结果。我对为什么我在应用Where子句时没有得到任何结果感到困惑,但是没有它,我得到了所有结果,而ID号就是这些结果的一部分。
答案 0 :(得分:0)
您的查询非常简单。我只能看到两个可能的问题:
没有Option Explicit
Public Sub SelectionTest()
Dim selection As Variant
Dim rng As Range
Dim UsedRange As Variant
Dim lastCell As Range
Set selection = Application.selection
Dim area As Range
Debug.Print "selection columns " & selection.Columns.Count
Dim finalRng As Range
Dim finalArr As Variant
For Each area In selection.Areas
Debug.Print "single rng columns " & area.Columns.Count
Set lastCell = area.Find(What:="*", After:=area.Cells(1, 1), LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious, MatchCase:=False)
Set lastCell = area.Find(What:="*", After:=area.Cells(1, 1), LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False)
Debug.Print lastCell
Next
End Sub
等于CLIENT
的{{1}}。
有一个符合该条件的ClienIdSubId
,但是'48079'
,CLIENT
或CLIENTADDRESS
中没有匹配的行。由于您正在使用 INNER JOINS 。
答案 1 :(得分:0)
很抱歉,我有正确的查询ClientIdSubId应该是ClientSubId。而不是ClientIdSubId。