REGEXP_SIMILAR - Search words order

Database

REGEXP_SIMILAR - Search words order

How can I make this into a single line so I don't have to check for both word occurance orders?

Basically I want to check for the cities in any order and return the state.

 

Case

WHEN REGEXP_SIMILAR( upper(myColumn),'MIAMI|ORLANDO') = 1

or

WHEN REGEXP_SIMILAR( upper(myColumn),'ORLANDO|MIAMI') = 1 THEN 'FLORIDA'

end as myState

  • REGEXP
  • REGEXP_SIMILAR
Tags (2)

Accepted Solutions

Re: REGEXP_SIMILAR - Search words order

Thanks, that helped get me to the solution that works:

 

Case

WHEN REGEXP_SIMILAR( upper(myColumn), '(MIAMI|ORLANDO)|(ORLANDO|MIAMI)' ) = 1

end as myState

1 ACCEPTED SOLUTION
2 REPLIES
Teradata Employee

Re: REGEXP_SIMILAR - Search words order

I don't know why that wouldn't work, although you may have to include both in parentheses for the OR to work:

(MIAMI)|(ORLANDO)

Re: REGEXP_SIMILAR - Search words order

Thanks, that helped get me to the solution that works:

 

Case

WHEN REGEXP_SIMILAR( upper(myColumn), '(MIAMI|ORLANDO)|(ORLANDO|MIAMI)' ) = 1

end as myState