sql select with 不包含
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15896644/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
sql select with does not contain
提问by user1794974
This is my select:
这是我的选择:
select MY_ID, JOB_ID
from MY_TABLE
where JOB_ID != 'bra%'
and JOB_ID != 'wes%'
and STS_DTTM < trunc (sysdate) -12
It still selects fields with values that contain "bra" and "wes"
它仍然选择值包含“bra”和“wes”的字段
Thank you & regards,
谢谢和问候,
回答by Florin Ghita
Should be:
应该:
select MY_ID, JOB_ID
from MY_TABLE
where JOB_ID not like 'bra%'
and JOB_ID not like 'wes%'
and STS_DTTM < trunc (sysdate) - 12;
And the column name should be job_name or job_code, not Job_id. Job_id sounds like a number :)
并且列名应该是job_name 或job_code,而不是Job_id。Job_id 听起来像一个数字 :)
回答by Chee mun Low
use NOT LIKE instead of !=
使用 NOT LIKE 而不是 !=
select MY_ID, JOB_ID
from MY_TABLE
where JOB_ID NOT LIKE'bra%'
and JOB_ID NOT LIKE 'wes%'
and STS_DTTM < trunc (sysdate) -12
回答by Xavier S.
I'am not sure, but this SQL request might works:
我不确定,但这个 SQL 请求可能有效:
select MY_ID, JOB_ID
from MY_TABLE
where NOT (JOB_ID LIKE 'bra%' OR JOB_ID LIKE 'wes%')
and STS_DTTM < trunc (sysdate) -12