473,799 Members | 3,084 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3873

"amwi" <am**@yahoo.com > wrote in message
news:6u******** ************@ne wsc.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******* ***********@new sb.telia.net>.. .
"amwi" <am**@yahoo.com > wrote in message
news:6u******** ************@ne wsc.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
248484
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 particular surname in a particular town. I can select the records fine with this syntax (testing in Oracle SQL* Plus) SELECT NAMEINFO.LASTNAME, NAMEINFO.FIRSTNAME, NAMEINFO.MIDDLENAME, NAMEINFO.GENDER, ADDRESSINFO.REGION FROM NAMEINFO, ADDRESSINFO...
5
4016
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 fieldX=valueX WHERE id IN (SELECT tX.id FROM tableX AS tX WHERE tX.fieldY=valueY AND filedZ=valueZ);
8
89321
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 tblMyTable.UniqueID = tblMyTableTEMP.UniqueID SET tblMyTable.myField = tblMyTableTEMP.myField, tblMyTable.myField2 = tblMyTableTEMP.myField2,
8
2722
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 that I could use the @@Identity command but cannot get this to function. Has anyone used this command with ASPUpload with an success, or any other methods that could be used? Thanks.
1
1826
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 when I have a 'datetime' column in the table. I tested this with a very simple sample table. As long as there is no datetime column either in the table or on the form, all are peachy. Here is the code, in case somebody can figure it out. I...
3
1842
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 Blow"). Using a ComboBox control is the only way I've found to do this (and its actually really easy) but I haven't found a way to disable everything and make that combo box just look like a standard label. The label control doesn't seem to...
4
7255
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 - "Modified" of type DateTime - is hidden since it should not be edited by a user. The system handles the update for this column. So, I have hidden (Visible=false) this column on the grid. In order to access the value in this field, I have created a...
2
465
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 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?
3
3968
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
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9538
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10249
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10025
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9068
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6804
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5461
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4138
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 we have to send another system
2
3755
muto222
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.