J
Joel_123
Hello,
I first off want to say thank you to all those who post on this site. I am
not very experienced in Access and the advice and direction offered here is
top notch!
I have been handed a database that has well data in it. There is a table
called Wells which has the following fields:
Well_ID
Well_Name
Well_Location
I also have another table called Well_Data. This table contains the well
data (specific descriptions of items/materials encountered down the well) for
each well. Each well can have numerous well data entries. The two tables
are joined on Well_ID. Here are the fields for the Well_Data Table:
Well_Data_ID
Well_ID
Item_Depth
Item_Description
I am writing a query to search on a specific Item_Description (let's say gold
). I need to be able to return the well name, well location, item depth,
item description, as well as the next item depth below the current item depth.
So for example, I would get a return of:
Well_Name: 40000
Well_Location: Some Place
Item Depth: 150
Item Description: Gold
Next Item Depth 250
I tried to build this by creating one query. I have no problems using ...
Like"*Gold*"... to get me the wells that have gold in them and the query is
relatively quick (being that there are over 2 million Well_Data_ID records).
The problem arises when I try to get the "Next Item Depth" value. The whole
query hangs and Access shuts down. I don't know if I just haven't let it run
long enough but I let it go for an hour and it still hung up. Here's how I
tried to do that:
NextItemDepthSelect Min(Item_Depth) from Well_Data Where Depth >
Well_Data_Alias.[Depth] and Well_ID = Well_Data_Alias.[Well_ID])
I know this works. I created a copy of the database and deleted over 2/3 of
the records and this query completed in about a minute. I was just wondering
if I can somehow re-structure this query to be more efficient. As for
indexes, I ran the analyzer and indexed the fields it told me to. It didn't
help at all.
Any Help would be greatly appreciated.
Thanks.
Joel
I first off want to say thank you to all those who post on this site. I am
not very experienced in Access and the advice and direction offered here is
top notch!
I have been handed a database that has well data in it. There is a table
called Wells which has the following fields:
Well_ID
Well_Name
Well_Location
I also have another table called Well_Data. This table contains the well
data (specific descriptions of items/materials encountered down the well) for
each well. Each well can have numerous well data entries. The two tables
are joined on Well_ID. Here are the fields for the Well_Data Table:
Well_Data_ID
Well_ID
Item_Depth
Item_Description
I am writing a query to search on a specific Item_Description (let's say gold
). I need to be able to return the well name, well location, item depth,
item description, as well as the next item depth below the current item depth.
So for example, I would get a return of:
Well_Name: 40000
Well_Location: Some Place
Item Depth: 150
Item Description: Gold
Next Item Depth 250
I tried to build this by creating one query. I have no problems using ...
Like"*Gold*"... to get me the wells that have gold in them and the query is
relatively quick (being that there are over 2 million Well_Data_ID records).
The problem arises when I try to get the "Next Item Depth" value. The whole
query hangs and Access shuts down. I don't know if I just haven't let it run
long enough but I let it go for an hour and it still hung up. Here's how I
tried to do that:
NextItemDepthSelect Min(Item_Depth) from Well_Data Where Depth >
Well_Data_Alias.[Depth] and Well_ID = Well_Data_Alias.[Well_ID])
I know this works. I created a copy of the database and deleted over 2/3 of
the records and this query completed in about a minute. I was just wondering
if I can somehow re-structure this query to be more efficient. As for
indexes, I ran the analyzer and indexed the fields it told me to. It didn't
help at all.
Any Help would be greatly appreciated.
Thanks.
Joel