Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sql select with does not contain

Tags:

sql

oracle

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"

Thank you & regards,

like image 912
user1794974 Avatar asked Apr 09 '13 08:04

user1794974


People also ask

Does not contain like in SQL?

The NOT LIKE operator in SQL is used on a column which is of type varchar . Usually, it is used with % which is used to represent any string value, including the null character \0 . The string we pass on to this operator is not case-sensitive.

Is <> and != The same in SQL?

Here is the answer – Technically there is no difference between != and <>. Both of them work the same way and there is absolutely no difference in terms of performance or result.


1 Answers

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 :)

like image 172
Florin stands with Ukraine Avatar answered Oct 21 '22 13:10

Florin stands with Ukraine