473,474 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Update through join

3 New Member
Hey! I'm kinda new to oracle. I usually solve problems fast, but cant get this one.

I got 2 tables:

Test_data which has columns:
Test_navn
Test_pakke

Test_def which has columns:
Test_navn
Pakke

Test_data.test_pakke is unpopulated, and i want to populate it with Test_def.pakke where Test_navn of the 2 tables match.


From my MySQL days, i used this:

Expand|Select|Wrap|Line Numbers
  1. update test_data as tda, test_def as tde
  2. set test_pakke = tde.pakke
  3. where tda.test_navn = tde.test_navn
But i get a "ORA-00971: missing SET keyword" error... I get that no matter how i construct it.

The tables holds thousands of records, so i hope to get this working.. So hope you can help.
May 2 '07 #1
4 17903
chandu031
78 Recognized Expert New Member
Hey! I'm kinda new to oracle. I usually solve problems fast, but cant get this one.

I got 2 tables:

Test_data which has columns:
Test_navn
Test_pakke

Test_def which has columns:
Test_navn
Pakke

Test_data.test_pakke is unpopulated, and i want to populate it with Test_def.pakke where Test_navn of the 2 tables match.


From my MySQL days, i used this:

Expand|Select|Wrap|Line Numbers
  1. update test_data as tda, test_def as tde
  2. set test_pakke = tde.pakke
  3. where tda.test_navn = tde.test_navn
But i get a "ORA-00971: missing SET keyword" error... I get that no matter how i construct it.

The tables holds thousands of records, so i hope to get this working.. So hope you can help.

Hi,

In oracle there is no update join as in MySQL where you can update two tables in a single statement. A workaround would be to use corelated query.
Your query should look something like this:

UPDATE TEST_DATA A
SET TEST_PAKKE = (SELECT PAKKE FROM TEST_DEF B WHERE A.TEST_NAVN = B.TEST_NAVN)

This should do the trick, although it will perform slowly when there are a very large number of records.
May 2 '07 #2
Melancolie
3 New Member
Thanks Chandu :)

However i found the solution just 2 minutes after i posted...

Almost similiar to yours..

update test_data a
set test_pakke = (select distinct pakke from test_def b where a.test_navn = b.test_navn)


Only took a few mins for 13421 records :)
May 2 '07 #3
debasisdas
8,127 Recognized Expert Expert
He said it will perform slowly because performance wise Corelated sub-queries are slowest.

Because while normal sub-query is evaluated only once for the table a
co-related sub-query is evaluated once per each row in the table

Again it depends on some other physical factors(hardware) also.
May 3 '07 #4
Melancolie
3 New Member
He said it will perform slowly because performance wise Corelated sub-queries are slowest.

Because while normal sub-query is evaluated only once for the table a
co-related sub-query is evaluated once per each row in the table

Again it depends on some other physical factors(hardware) also.
Thats correct :) But it was a one time update to expand a table and drop another one, so performance wasnt an issue..
May 3 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Narine | last post by:
Hi All, I need to write one complicated update statement and I'm looking at maybe finding a simpler way to do it. I have 2 tables: 1.Photo Table PhotoID FileName 1 111.jpg
17
by: kalamos | last post by:
This statement fails update ded_temp a set a.balance = (select sum(b.ln_amt) from ded_temp b where a.cust_no = b.cust_no and a.ded_type_cd = b.ded_type_cd and a.chk_no = b.chk_no group by...
2
by: serge | last post by:
/* This is a long post. You can paste the whole message in the SQL Query Analyzer. I have a scenario where there are records with values pointing to wrong records and I need to fix them using an...
9
by: Vorpal | last post by:
Here is a small sample of data from a table of about 500 rows (Using MSSqlserver 2000) EntryTime Speed Gross Net ------------------ ----- ----- 21:09:13.310 0 0 0 21:09:19.370 9000 ...
4
by: 001 | last post by:
Hello, The select statement needs only 1 second to complete the query. But the update statement spends 30 minutes. Why? SELECT STATEMENT: declare @IDate smalldatetime select @IDate=col001...
2
by: Mike Leahy | last post by:
Hello all, This question is related to updating tables - is there any way to calculate or update the values in a column in a table to the values in a field produced by a query result? An...
4
by: deko | last post by:
I'm trying to update the address record of an existing record in my mdb with values from another existing record in the same table. In pseudo code it might look like this: UPDATE tblAddress SET...
2
by: Sim Zacks | last post by:
The following query updated all the rows in the AssembliesBatch table, not just where batchID=5. There are 2 rows in the AssembliesBatch table with batch ID of 5 and I wanted to update both of...
0
by: svgeorge | last post by:
I want to update several tables using one stored procedure. How can i do this I mean the syntax.etc. declaration etc. I know the basic syntax as below CREATE PROCEDURE <Procedure_Name, sysname,...
3
by: Michel Esber | last post by:
Hi all, DB2 V8 LUW FP 15 There is a table T (ID varchar (24), ABC timestamp). ID is PK. Our application needs to frequently update T with a new value for ABC. update T set ABC=? where ID...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.