Update with a join.


 
Thread Tools Search this Thread
Top Forums Programming Update with a join.
# 1  
Old 02-18-2010
Update with a join.

Hello,
Can someone help me correct this statement.
Code:
Update TESTDTA.F0101
Set F0101.ABAN86='5253'
WHERE F03012.AIAN8 = F0101.ABAN8 AND ((F03012.AICO='00219') AND (F03012.AIAC21='H27'));

Thanks
Sam

Last edited by radoulov; 02-18-2010 at 03:35 PM.. Reason: scottn: Code tags please...; radoulov: adjusted the title
# 2  
Old 02-18-2010
Something like this (untested):

Code:
update TESTDTA.F0101
set F0101.ABAN86='5253'
from TESTDTA.F0101, TESTDTA.F03012
WHERE F03012.AIAN8 = F0101.ABAN8 
AND (
  (F03012.AICO='00219') 
  AND (F03012.AIAC21='H27')
  );

What database is this?
# 3  
Old 02-18-2010
Oracle 9

The database is oracle. I tried but still not working.
# 4  
Old 02-18-2010
What do you mean by "not working"? Do you get an error?
# 5  
Old 02-18-2010
yes

Missing impression, and high lights the FROM or = in the statement. I tried all different but still not executing. I am wondering if there is different way to write the statement. thanks

Code:
update TESTDTA.F0101
set F0101.ABAN86='5253'
from TESTDTA.F0101, TESTDTA.F03012
WHERE F03012.AIAN8 = F0101.ABAN8 
AND (
  (F03012.AICO='00219') 
  AND (F03012.AIAC21='H27')
  );
------------------
Update TESTDTA.F0101
Set ABAN86='5253'
Where (select F03012.AIAN8 = F0101.ABAN8 from TESTDTA.F03012.ABAN8
AND ((F03012.AICO='00219') 
  AND (F03012.AIAC21='H27')));


Last edited by pludi; 02-19-2010 at 01:49 AM.. Reason: code tags, please...
# 6  
Old 02-18-2010
Yep,
the from keyword in the update/delete statements is not standard.
I'll test it tomorrow, in the meantime try this:

Code:
update TESTDTA.F0101
set F0101.ABAN86='5253'
where exists (
  select null 
  from TESTDTA.F03012
  where F03012.AIAN8 = F0101.ABAN8
  and (
    (F03012.AICO='00219')
    and (F03012.AIAC21='H27')
    )
  );

# 7  
Old 02-18-2010
It Worked

Great it worked.

Thank you sooo much Sir,


Sam
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Join, merge, fill NULL the void columns of multiples files like sql "LEFT JOIN" by using awk

Hello, This post is already here but want to do this with another way Merge multiples files with multiples duplicates keys by filling "NULL" the void columns for anothers joinning files file1.csv: 1|abc 1|def 2|ghi 2|jkl 3|mno 3|pqr file2.csv: 1|123|jojo 1|NULL|bibi... (2 Replies)
Discussion started by: yjacknewton
2 Replies

2. Red Hat

RedHat 5 update 9 BASH update issue

Hi i want to update the BASH because of the "shell shock" vulnerability. my RedHat 5 is clean install with the default mirror site. when im running the command: yum update bash im getting a message saying there is no update. you can see in the attach picture... what am i doing wrong? is... (4 Replies)
Discussion started by: guy3145
4 Replies

3. Programming

Update a column from a Join

Here is my select that I have to identify the child records that are Open (e.c7 < 6000) when the parent (t2068) c.c7 > 3 SELECT c.c1000000161, c.c7, c.c1000000019, e.c1000000829 FROM t2068 c INNER JOIN t1533 e ON e.c1000000829 = c.c301572100 where c.c7 > 3... (2 Replies)
Discussion started by: newborndba
2 Replies

4. Programming

MYSQL - trigger update on record insert or update

Right I have a MYSQL database with table1 with 3 columns, colA, colB and colC. I want to combine the data in the 3 columns into a 4th column names col_comb. Here's the SQL command that works: UPDATE table1 SET `col_comb` = CONCAT( `colA` , ' - ', `colB` , ', ', `colC` ); So now I want this... (5 Replies)
Discussion started by: barrydocks
5 Replies

5. UNIX for Dummies Questions & Answers

How to use the the join command to join multiple files by a common column

Hi, I have 20 tab delimited text files that have a common column (column 1). The files are named GSM1.txt through GSM20.txt. Each file has 3 columns (2 other columns in addition to the first common column). I want to write a script to join the files by the first common column so that in the... (5 Replies)
Discussion started by: evelibertine
5 Replies

6. UNIX for Dummies Questions & Answers

how to join two files using "Join" command with one common field in this problem?

file1: Toronto:12439755:1076359:July 1, 1867:6 Quebec City:7560592:1542056:July 1, 1867:5 Halifax:938134:55284:July 1, 1867:4 Fredericton:751400:72908:July 1, 1867:3 Winnipeg:1170300:647797:July 15, 1870:7 Victoria:4168123:944735:July 20, 1871:10 Charlottetown:137900:5660:July 1, 1873:2... (2 Replies)
Discussion started by: mindfreak
2 Replies

7. UNIX for Dummies Questions & Answers

Join 2 files with multiple columns: awk/grep/join?

Hello, My apologies if this has been posted elsewhere, I have had a look at several threads but I am still confused how to use these functions. I have two files, each with 5 columns: File A: (tab-delimited) PDB CHAIN Start End Fragment 1avq A 171 176 awyfan 1avq A 172 177 wyfany 1c7k A 2 7... (3 Replies)
Discussion started by: InfoSeeker
3 Replies

8. Programming

sql,multiple join,outer join issue

example sql: select a.a1,b.b1,c.c1,d.d1,e.e1 from a left outer join b on a.x=b.x left outer join c on b.y=c.y left outer join d on d.z=a.z inner join a.t=e.t I know how single outer or inner join works in sql. But I don't really understand when there are multiple of them. can... (0 Replies)
Discussion started by: robbiezr
0 Replies

9. Shell Programming and Scripting

join (pls help on join command)

Hi, I am a new learner of join command. Some result really make me confused. Please kindly help me. input: file1: LEO oracle engineer 210375 P.Jones Office Runner ID897 L.Clip Personl Chief ID982 S.Round UNIX admin ID6 file2: Dept2C ID897 6 years Dept5Z ID982 1 year Dept3S ID6 2... (1 Reply)
Discussion started by: summer_cherry
1 Replies
Login or Register to Ask a Question