Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace multiple strings in a Teradata select statement

Tags:

sql

teradata

I need to select from a table, but remove various strings. Let's say entries in my table are:

DataMart1:Here is some data and other valuable data
HouseWareMart Other data possibly junk data
DataLake3 there is nothing here

And I want to remove various strings: "Valuable data" "Other data " "there is nothing "

So I would get:

DataMart1:Here is some data and other
HouseWareMart possibly junk data
DataLake3 here

I thought about nesting OREPLACE, but couldn't get the syntax right, and searching 'Nested OREPLACE' returned nothing helpful.

Any suggestions?

like image 552
Al__H Avatar asked May 12 '26 02:05

Al__H


1 Answers

The syntax for nested replace:

select oreplace(oreplace(oreplace(col, 'Valuable data', ''), 'Other data ', ''), 'there is nothing ', '')
like image 159
Gordon Linoff Avatar answered May 14 '26 16:05

Gordon Linoff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!