我在選擇語句下運行,並100%確定第二行導致問題,因爲子查詢運行良好。SQL服務器選擇子查詢錯誤
是Where (first,second) IN
有效聲明?
我正在做這個查詢的原因是,我將然後用刪除替換第一個選擇,所以我只是想確保我得到我想要的設置。
select * from edit_proj_isbn e
where (e.record_id, e.proj_isbn)
IN
(
select t_r.record_id, t_r.proj_isbn from editorial e,
(
select ed.record_id as record_id, substring(d.file_name, 1, 13) as epubisbn, epi.proj_isbn as proj_isbn, ed.asset_subtype as asset_subtype
from editorial ed join doc_renditions d on ed.record_id = d.record_id join edit_proj_isbn epi on ed.record_id = epi.record_id
where (ed.asset_subtype like 'epub' or ed.asset_subtype like 'updf')
and substring(d.file_name, 1, 13) not like epi.proj_isbn
) AS t_r
where t_r.record_id=e.record_id
)
我得到以下錯誤,與第二行強調:
消息4145,級別15,狀態1,行2
在上下文,其中指定的非布爾類型的表達式一個條件是預計的,靠近','。
感謝, 布魯斯
你可能不希望使用表的別名'e'兩次。它可能會令人困惑。 – HABO 2012-08-09 18:21:19