473,394 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

update table a.fkid from table b.pkid

I have tried to solve this on my own for a long time now, so i really need
some help here...

I use Oracle 10.1 and SQL *plus 10.1.

How do i update table a.fkid from table b.pkid with the following "rule".
The table b.pkid's should be evenly distributed over table a as fkid's.

Does anyone have a tip on how to solve this?

Thank you.
Jul 19 '05 #1
2 3848

"amwi" <am**@yahoo.com> wrote in message
news:6u********************@newsc.telia.net...
I have tried to solve this on my own for a long time now, so i really need
some help here...

I use Oracle 10.1 and SQL *plus 10.1.

How do i update table a.fkid from table b.pkid with the following "rule".
The table b.pkid's should be evenly distributed over table a as fkid's.

Does anyone have a tip on how to solve this?

Thank you.

An example:

Table b contains 10 rows with specific id's (primary keys).
Table a contains 10000 rows and contains a fk to table b.id.
The problem is to update the 10000 fk's in table a so that the 10 pk's in
table a is spread evenly into 10000 items in table a.

That is:
The first id in table b is written to 1000 rows in table a.
The second id in table b is written to the next 1000 rows in table a.
....
The twentieth id in table b is written to the last 1000 rows in table a.

This is the basic idea and it should be real easy to solve in SQL,
somehow...

Thank you
Jul 19 '05 #2
"amwi" <am**@yahoo.com> wrote in message news:<FB******************@newsb.telia.net>...
"amwi" <am**@yahoo.com> wrote in message
news:6u********************@newsc.telia.net...
I have tried to solve this on my own for a long time now, so i really need
some help here...

I use Oracle 10.1 and SQL *plus 10.1.

How do i update table a.fkid from table b.pkid with the following "rule".
The table b.pkid's should be evenly distributed over table a as fkid's.

Does anyone have a tip on how to solve this?

Thank you.

An example:

Table b contains 10 rows with specific id's (primary keys).
Table a contains 10000 rows and contains a fk to table b.id.
The problem is to update the 10000 fk's in table a so that the 10 pk's in
table a is spread evenly into 10000 items in table a.

That is:
The first id in table b is written to 1000 rows in table a.
The second id in table b is written to the next 1000 rows in table a.
...
The twentieth id in table b is written to the last 1000 rows in table a.

This is the basic idea and it should be real easy to solve in SQL,
somehow...

Thank you


You should ask your professor for help. If you want help with homework
in this group, you should:
try to write the SQL on your own.
If you cannot do it, post what you tried and we will lend some
guidance.
(we will not do your homework for you.)

Here's a hint via a question: Is there a way, using the current
columns and data in table a to groups the values in sets of 1000?

IOW can a query like

SELECT count(*),<some column list>
FROM table a
GROUP BY <some column list> ;

result in 10 rows with counts of about 1000 for each?

HTH,
ed
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a...
5
by: red85 | last post by:
hello i have mysql 4.1 with win2000 SP3, i know that it is only an alpha and i don't know if someone else has already posted this problem: when i execute this sql UPDATE tableX SET...
8
by: Lauren Quantrell | last post by:
In VBA, I constructed the following to update all records in tblmyTable with each records in tblmyTableTEMP having the same UniqueID: UPDATE tblMyTable RIGHT JOIN tblMyTableTEMP ON...
8
by: BigJohnson | last post by:
We're using ASPUpload as a tool to upload files to our server and save the details to SQLServer. However, I have an application where I need to return the pkID of the just saved file. I'm assuming...
1
by: BabuMan | last post by:
Hi, I have a FormView control on a page which is bound to a SQLDataSource table. Everything works fine except for the "Update". I get an InvalidCastException. The problem only seems to surface...
3
by: Ryan | last post by:
I have a form that contains a field that is a Foreign Key (UserID) I want this control to have a "label" appearance but I want it to act as a lookup table (SelectedValue = FKID, SelectedText = "Joe...
4
by: =?Utf-8?B?QmFidU1hbg==?= | last post by:
Hi, I have a GridView and a SqlDataSource controls on a page. The SqlDataSource object uses stored procedures to do the CRUD operations. The DataSource has three columns one of which -...
2
by: amwi | last post by:
I have tried to solve this on my own for a long time now, so i really need some help here... I use Oracle 10.1 and SQL *plus 10.1. How do i update table a.fkid from table b.pkid with the...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.