嵌套选择不排除数据

问题描述 投票:0回答:1

我正在构建这个select语句,并且达到了我的条件不起作用的程度。这是代码:

select * 
from (
select ref,usr1,design,forref,replace(stock,'.',',')as stock 
from st
where inactivo like '0' 
and usr1 not in ('Serv','Reciclagem','portes','pbl','ctb','') 
and forref not in ('','0')
     ) total
where ref not in ('10159%','13159%')
order by usr1

问题是,当我写行以排除ref表上的某些值时,没有任何反应。

where ref not in ('10159%','13159%')

哪里错了?

sql sql-server select nested
1个回答
0
投票

尝试使用

WHERE LEFT(ref, 5) NOT IN ('10159','13159')

HTH!

谢谢。

© www.soinside.com 2019 - 2024. All rights reserved.