0

我在 select 语句下方运行,并且 100% 确定第二行导致问题,因为子查询运行良好。

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 行
在预期条件的上下文中指定的非布尔类型表达式,靠近“,”。

谢谢,布鲁斯

4

2 回答 2

2

Where (first,second) IN 是一个有效的语句吗?

不,这不是一个有效的陈述。WHERE您需要为每一个单独的子句。

于 2012-08-09T18:11:03.853 回答
0

使用 CTE 的快速赃物:

with Timmy as (
  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 )
select * from edit_proj_isbn
  where record_id in ( select t_r.record_id from Timmy ) and proj_isbn in ( select t_r.proj_isbn from Timmy )
于 2012-08-09T18:22:55.427 回答