|
-
Help in Update Statement
Hello everyone..
I need help here in Writing this update statement on a Column 'emailaddr_'. One of our Clients have changed their emai Domain from say abc.com to xyz.com. I need to update all the Rows that abc.com to xyz.com.
For eg.
Source Table Column
--------------------
[email protected]
[email protected]
target Table
------------
[email protected]
[email protected]
I have like 950 Records whose email domain needs to be changed.
Can anyone help me here in Writing a sq ?..
Any help is appreciated
Ron
-
Look at the REPLACE function in sql.
"The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb
-
UPDATE table_name set column_name=replace(column_name,'abc.com','xyz.com')
Assuming that abc.com comes only as the domain name.
HTH.
-
And that there isn't a domain with fred_abc.com
Try
UPDATE table_name set column_name=replace(column_name,'@abc.com','@xyz.com')
where substr(column_name,-1*length(@abc.com')) ='@abc.com'
-
thanks a lot guys....appreciate it.
Ron
-
 Originally Posted by gamyers
where substr(column_name,-1*length(@abc.com')) ='@abc.com'
I think that is the same thing as
WHERE column_name LIKE '%@abc.com'
-
The LIKE should be fine in this context.
Generally, I prefer to use an equals because there's the potential for the contents of a variable to include LIKE wildcard characters (_ and %) which can confuse the result
EG
SELECT * from table(sys.dbms_debug_vc2coll ('@test.com','@tast.com','@t_st.com'))
where column_value like '%@t_st.com'
However, I did a quck check and these characters shouldn't be in the domain name so the issue should not arise
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|