5

这是我的选择:

select MY_ID, JOB_ID
from MY_TABLE
where JOB_ID != 'bra%'
and JOB_ID != 'wes%'
and STS_DTTM < trunc (sysdate) -12

它仍然选择值包含“bra”和“wes”的字段

谢谢和问候,

4

3 回答 3

8

应该:

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 听起来像一个数字:)

于 2013-04-09T08:15:01.453 回答
3

使用 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
于 2013-04-09T08:15:25.800 回答
1

我不确定,但这个 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
于 2013-04-09T08:17:41.393 回答