tan
tan

Reputation: 19

ORACLE SQL: how to get text before a specific word

Using Oracle,

  1. how can i get the text before a specific word(CITY) including the word CITY

Sample:

22nd street westlake 1378 california city 
32nd street texas 1111 houston city

Result:

California city 
Houston city
  1. Removing the city from item#1.

Sample:

22nd street westlake 1378 california city 
32nd street texas 1111 houston city

Result:

22nd street westlake 1378
32nd street texas 1111

updated the question. thanks

Upvotes: 0

Views: 163

Answers (1)

Popeye
Popeye

Reputation: 35930

It seems like you need to remove string or numbers from your string.

Try to use regexp_replace as follows:

1.

regexp_replace( '1378 california city 1111 houston city' , '[^0-9 ]')
regexp_replace( '1378 california city 1111 houston city' , '[0-9]')

Check the complete example here: Db<>fiddle

Upvotes: 1

Related Questions