2013-06-28 45 views
-2

我試圖做的事 - 哪裏的doctype不爲空(DOCTYPE = documenttype)凡不爲空文件= DOCTYPE

我看了一下MSDN上的SQL中的not null和where子句我好像沒有,可以到找到什麼。 我最後的嘗試是

where DocType is not null (f4111dt.DocType=f0911.documenttype) 

但它扔了周圍f4111dt一個錯誤,是不是一個問題

如果我只是有其中4111dt.DocType = f0911dt.documenttype

然後我失去了4111dt.DocType中的空值(我想要的),因爲它們與f0911dt.documenttype中的任何內容都不匹配。

但是,如果我沒有在聲明4111dt.DocType = f0911dt.documenttype 的文檔類型不會匹配......

+0

你不只是缺少一個'和'這樣:'這裏的DocType不爲空AND(f4111dt.DocType = f0911.documenttype)' – DaveHogan

+1

認罪se解釋什麼'doctype不爲空(doctype = documenttype)'意在表示。 –

+2

@DaveHogan - 在這種情況下,只需'f4111dt.DocType = f0911.documenttype'就足夠了,就好像'DocType'是'NULL',將永遠是TRUE; –

回答

3

如果你想也把那些其中,文檔類型爲null:

Where DocType is null OR (f4111dt.DocType=f0911.documenttype) 
+0

謝謝,這與我的文檔類型相匹配 – NeverEnding

2

試試這個

where DocType is not null AND (f4111dt.DocType=f0911.documenttype) 
+0

謝謝你的回答,雖然我說這是我想要的,但這並沒有讓我獲得正確的結果 – NeverEnding