Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Negation Regular Expressions in Queries

Status
Not open for further replies.

GoTerps88

Programmer
Apr 30, 2007
174
US
I'm trying to use a negation of a regular expression with no avail. What I am trying to do is create a query that does not match the search string. Yes, I know you can do this with a NOT LIKE expression, but want to do this with a regular expression because I will have to add other conditions to the expression.

For example, I want to find all occurrence in the field last_name that don't begin with the letter O. This works:

Code:
SELECT last_name
FROM employees
WHERE REGEXP_LIKE('^[^O]');

However how would I accomplish finding all occurrences of a string string that is not 'olse'? The occurrences would not necessary begin at the start of the string. They could be in any part of the string.

Thanks in advance.
 
This seems to work:

Code:
SELECT last_name
FROM employees
WHERE NOT REGEXP_LIKE('olse');

But how could I do this with the negation caret^ instead of using NOT REGEXP_LIKE?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top