Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Arithmatic operation on colunms of different table

Author  Topic 

is_munir
Starting Member

1 Post

Posted - 2008-07-03 : 06:11:11
I have been created two tables namely ‘Tab1’ and ‘Tab2’ in SQL Plus 8.0 and inserted some data i.e.

Tab1.
id. name sal
1 ABC 1500
2 XYZ 2000
3 JKL 2500

Tab2.
id. inc
1 500

Problem is that when I performed update statement like

SQL> UPDATE tab1
2 SET sal = sal + tab2.inc;


I received following error:

set sal=sal + tab2.inc
*
ERROR at line 2:
ORA-00904: invalid column name

elancaster
A very urgent SQL Yakette

1208 Posts

Posted - 2008-07-03 : 06:13:20
you should note this is a forum for Microsoft SQL Server

Em
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-03 : 06:15:18
[code]UPDATE t1
SET t1.sal = t1.sal + t2.inc
FROM tab1 t1
INNER JOIN tab2 t2
on t2.id=t1.id[/code]

try like above. it should work (it works in MS SQL Server not sure if anything different in Oracle). if its not working try posting it in oracle forums. this is MS SQL Server forum.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-07-03 : 10:33:56
quote:
Originally posted by visakh16

UPDATE t1
SET t1.sal = t1.sal + t2.inc
FROM tab1 t1
INNER JOIN tab2 t2
on t2.id=t1.id


try like above. it should work (it works in MS SQL Server not sure if anything different in Oracle). if its not working try posting it in oracle forums. this is MS SQL Server forum.


Update with Inner Join will work only in MS SQL Server and Access

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -