In my Access database, I have three tables, as follows:
Tracts - information about tracts. Each tract has a key.
Leases - information about leases. Each lease has a key.
In addition, I have an Ownership table, which contains records linking
Tracts and Leases. Not all Tracts have a record in the Ownership
table, and some (most) tracts have more than one.
What I want is to create something like an update query that will plug
information into a field in the tract table. The information I want
to plug in is this (sorry, this gets a little complex): for the
ownership records connected to that tract, look up each lease, and in
the Leases table, find their expiration dates, and what is the
earliest one?
In other words, if I had this information:
Tracts Table:
tract id tract size earliest exp date
--------------------------------------------
1 450
2 300
3 240
Leases Table:
lease id expiration date
---------------------------
a 01/02/2003
b 04/06/2004
c 12/31/2002
Ownership Table:
ownership key tract id lease id percentage
-------------------------------------------------------
1 1 a 20
2 1 b 40
3 2 a 10
4 2 c 90
...then I want the result of my query to be making the Tracts Table
like this:
tract id tract size earliest exp date
--------------------------------------------
1 450 01/02/2003
2 300 12/31/2002
3 240
Please ask for clarification if this makes sense. Obviously this is a
simplification of the actual data I'm working with.
By the way, I have experience with select and update queries, and can
read SQL but not generally generate it. I'm reasonably
computery/logical/technical, though.
Thanks in advance!
Tam |
Clarification of Question by
tamkins-ga
on
19 Feb 2003 08:03 PST
I want it to overwrite where there is already an expiration date.
Also, I'm using Access 2000.
More than accomplishing this specific goal, I am using this problem as
an example so that I can learn to do this general kind of thing, which
I need to do a lot of different kinds of. I may post more questions
along the same lines later, if I can't figure out the general pattern.
Thanks again, and sorry I took so long to clarify.
|