这是我的选择:
select MY_ID, JOB_ID
from MY_TABLE
where JOB_ID != 'bra%'
and JOB_ID != 'wes%'
and STS_DTTM < trunc (sysdate) -12
它仍然选择值包含“bra”和“wes”的字段
谢谢和问候,
应该:
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;
并且列名应该是job_name 或job_code,而不是Job_id。Job_id 听起来像一个数字:)
使用 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
我不确定,但这个 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