Home » SQL & PL/SQL » SQL & PL/SQL » sql query to update some rows in a table
sql query to update some rows in a table [message #7698] Tue, 01 July 2003 13:09 Go to next message
frnd
Messages: 2
Registered: July 2003
Junior Member
sample data in column should be transformed to

1234 asdfgh ap.----------->1234 asd fgh ap.
567 E. asdfgh ------------>567 E. asd fgh
234 asdfgh ap ----------->234 asd fgh ap
Re: sql query to update some rows in a table [message #7699 is a reply to message #7698] Tue, 01 July 2003 13:20 Go to previous messageGo to next message
Art Metzer
Messages: 2480
Registered: December 2002
Senior Member
quote from frnd:
----------------------------------------------------------------------
sample data in column should be transformed to 

1234 asdfgh ap.----------->1234 asd fgh ap. 
567 E. asdfgh ------------>567 E. asd fgh 
234 asdfgh ap ----------->234 asd fgh ap 

----------------------------------------------------------------------
SQL> CREATE TABLE t (addr VARCHAR2(20));
  
Table created.
  
SQL> INSERT INTO t VALUES ('1234 asdfgh ap.');
  
1 row created.
  
SQL> INSERT INTO t VALUES ('567 E. asdfgh');
  
1 row created.
  
SQL> INSERT INTO t VALUES ('234 asdfgh ap');
  
1 row created.
  
SQL> COMMIT;
  
Commit complete.
  
SQL> <font color=blue>UPDATE t</font>
  2  <font color=blue>SET    t.addr = REPLACE(t.addr</font>
  3  <font color=blue>                ,       'asdfgh'</font>
  4  <font color=blue>                ,       'asd fgh')</font>
  5  <font color=blue>WHERE  INSTR(t.addr</font>
  6  <font color=blue>       ,     'asdfgh') > 0;</font>
  
3 rows updated.
  
SQL> COMMIT;
  
Commit complete.
  
SQL> SELECT addr FROM t;
  
ADDR
--------------------
1234 asd fgh ap.
567 E. asd fgh
234 asd fgh ap
  
SQL> 
Re: sql query to update some rows in a table [message #7702 is a reply to message #7699] Tue, 01 July 2003 13:47 Go to previous message
frnd
Messages: 2
Registered: July 2003
Junior Member
Hi.... thank u for the reply .. it worked here ...
Previous Topic: Help needed..Very Urgent for me..Plz help..
Next Topic: server.urlencode kinda function
Goto Forum:
  


Current Time: Fri Apr 19 23:07:56 CDT 2024