Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Question about not like operator

SeshuGiriNov 5 2010 — edited Nov 5 2010
HI,


This where clause omitting ABC% , but I wanted to exclude some conditions I want my sql to return COLUMNA = 'ABCD' but exclude everything else 'ABC%'
how do I fix this?

WHERE COLUMNA NOT LIKE '%ABC'
AND COLUMNA NOT LIKE 'ABC%'
AND COLUMNA NOT LIKE '%XYZ'
AND COLUMNA NOT LIKE 'XYZ%'

Expected result:
ABCD
AAAA
BBBB
etc
This post has been answered by Frank Kulash on Nov 5 2010
Jump to Answer

Comments

Frank Kulash
Answer
Hi,

Here's one way:
WHERE   COLUMNA NOT LIKE '%ABC' 
AND 	(   COLUMNA NOT LIKE 'ABC%' 
	OR  COLUMNA  =	     'ABCD'
	)
AND 	COLUMNA NOT LIKE '%XYZ' 
AND 	COLUMNA NOT LIKE 'XYZ%' 
Marked as Answer by SeshuGiri · Sep 27 2020
1 - 1
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 3 2010
Added on Nov 5 2010
1 comment
103 views