473,406 Members | 2,312 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,406 software developers and data experts.

how to use SQL INSERT INTO and maintain referential integrity

Hello,
This should be a fairly simply SQL question. I have a list of scores which i want to associate with districts in my Access database. right now it is set up:

tbldistrict
distid name distcode rankid

tblranking
rankid ranking00 ranking90

where distid and rankid are PK and rankid is foreign key in tbldistrict.
I want to populate two tables from the list of information I have. The distcode is used to identify which scores from the list go to which district. Using

[code]
INSERT INTO ranking (dfg00, dfg90)
SELECT dfg.[2000DFG], dfg.[1990DFG]
FROM dfg, district
WHERE district.distcode = dfg.[District Code];
[\CODE]

will populate my ranking table but how do I match the foreign key value in tblDistrict? Hopefully I explained this well.
Nov 6 '06 #1
1 1959
PEB
1,418 Expert 1GB
So a view tells that you can do this one:

INSERT INTO ranking (dfg00, dfg90, rankid)
SELECT dfg.[2000DFG], dfg.[1990DFG], distid
FROM dfg, district
WHERE district.distcode = dfg.[District Code];
Nov 6 '06 #2

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

Similar topics

16
by: robert | last post by:
been ruminating on the question (mostly in a 390/v7 context) of whether, and if so when, a row update becomes an insert/delete. i assume that there is a threshold on the number of columns of the...
7
by: Jimmie H. Apsey | last post by:
Referential Integrity on one of our production tables seems to have been lost. I am running Postgres 7.1.3 embedded within Red Hat kernel-2.4.9-e.49. Within that I have a table with referential...
5
by: Geisler, Jim | last post by:
So, as far as I know, PostgreSQL does not have any way of verifying the loss of referential integrity. Are there any recommended methods or utilities for checking referential integrity in a...
6
by: heyvinay | last post by:
I have transaction table where the rows entered into the transaction can come a result of changes that take place if four different tables. So the situation is as follows: Transaction Table...
80
by: Andrew R | last post by:
Hi I'm creating a series of forms, each with with around 15-20 text boxes. The text boxes will show data from tables, but are unbound to make them more flexible. I want the form to be used...
3
by: moskie | last post by:
Is there a way to run an alter table statement that adds a constraint for a foreign key, but does *not* check the existing data for refrential integrity? I'm essentially looking for the equivalent...
4
by: unwantedspam | last post by:
Hi All, Thank you in advance. I am trying to insert into two tables but I am getting the following error: "You cannot add or change a record because a related record is required in table..." I am...
2
by: Aggelos | last post by:
Hello, I am trying to develop a class that I will be able to maintain my relationships dynamically. For example I have the class employee and class company an employ has a Foreign Key companyId...
2
by: ApexData | last post by:
Access2000, using a continuous form. I’m getting a message that say “you cannot add or change a record because a related record is required in table Employee”. This occurs in all my combobox...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.