2017-10-21 85 views
1

我做SQLite中以下查询:的SQLite3:括号不能在子查询中不允许使用除和工会

select * from filenames f 
where (f.filesize,f.checksum) in 
    (
     select g.filesize,g.checksum from filenames g 
     where g.volume = 'Media' 
     except 
     select * from OnNNNMedia 
     union 
     select * from OnNNNTV 
    ) 
and f.volume='Media' 

该查询运行良好,但有一个逻辑问题,因为exceptunion之前,虽然我希望它执行之后执行。

如果我在union的周围加上括号以确保它先执行,请参阅下面的查询,我得到一个语法错误,抱怨新的括号。

select * from filenames f 
where (f.filesize,f.checksum) in 
    (
     select g.filesize,g.checksum from filenames g where g.volume = 'Media' 
     except 
     (
     select * from OnNNNMedia 
     union 
     select * from OnNNNTV 
     ) 
    ) 
and f.volume='Media' 

OnNNNMediaOnNNNTV是返回意见的文件大小,校验和对

回答

相关问题