Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Oracle

SQL> desc t1
Name Null? Type
-------------------------------
NO NOT NULL NUMBER(38)
TID NUMBER(38)
 
SQL> desc t2
Name Null? Type
----------------------------------
TID NOT NULL NUMBER(38)
NM CHAR(10)
NUM NUMBER(38)
 
SQL> update t1,t2
2 SET t2.num=220333
3 where t1.tid=t2.tid
4 and t1.no=1
5 ;

 
update t1,t2
*
ERROR at line 1:
ORA-00971: missing SET keyword
 
I want to update column of t2 but using column of table t1.
Posted 12-Feb-13 22:44pm
surkhi623
Edited 12-Feb-13 22:46pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try:
UPDATE  t2
SET     t2.num = 220333
WHERE   EXISTS(
    SELECT  1
    FROM    t1
    WHERE   t1.tid=t2.tid
    AND     t1.no=1
    )
  Permalink  
Comments
cool_sari at 14-Feb-13 0:37am
   
Thanx for it...
So,I have to select the row number to which I want to modify in select statement(select 1,select 2,select3........)
right???
Jörgen Andersson at 14-Feb-13 2:18am
   
No, the constant is only so that a row gets selected for the EXISTS clause. For an EXISTS to work you can select anything.
http://www.techonthenet.com/sql/exists.php
I prefer to select a constant instead of the standard * because I've been told it uses less memory. I have never controlled that statement though. Have checked it now, it doesn't matter, you can select whatever you want.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 278
1 Nguyen.H.H.Dang 230
2 Maciej Los 205
3 Peter Leow 195
4 arvind mepani 187


Advertise | Privacy | Mobile
Web03 | 2.8.140709.1 | Last Updated 13 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid