A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

updating muliple rows in one table based on information in another



 
 
Thread Tools Display Modes
  #1  
Old March 4th, 2010, 06:39 PM posted to microsoft.public.access
Al
external usenet poster
 
Posts: 470
Default updating muliple rows in one table based on information in another

I have 2 access tables...table 1 contains a street name and a low number and
a high number as well as a route number. I wish to update table 2 which has
a row for each address. If the street matches and the address is within the
range, I want to update the route number in table 2. There are multiple rows
in table 1 for each street name.

Both tables are quite - table 1 has 18,000 rows and table 2 has 500,000
rows.

Any suggestions would be greatly appreciated.
  #2  
Old March 4th, 2010, 07:51 PM posted to microsoft.public.access
Al Campagna[_2_]
external usenet poster
 
Posts: 1,462
Default updating muliple rows in one table based on information in another

Al,
Please give some sample/example values from each table, with field
names.
"This is what I have... vs... this is what I want."
Explain the logic you would use if you were to manually update the
second, from the first.
--
hth
Al Campagna
Microsoft Access MVP 2007-2009
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

"Al" wrote in message
...
I have 2 access tables...table 1 contains a street name and a low number
and
a high number as well as a route number. I wish to update table 2 which
has
a row for each address. If the street matches and the address is within
the
range, I want to update the route number in table 2. There are multiple
rows
in table 1 for each street name.

Both tables are quite - table 1 has 18,000 rows and table 2 has 500,000
rows.

Any suggestions would be greatly appreciated.



  #3  
Old March 4th, 2010, 08:31 PM posted to microsoft.public.access
John W. Vinson
external usenet poster
 
Posts: 18,261
Default updating muliple rows in one table based on information in another

On Thu, 4 Mar 2010 10:39:02 -0800, Al wrote:

I have 2 access tables...table 1 contains a street name and a low number and
a high number as well as a route number. I wish to update table 2 which has
a row for each address. If the street matches and the address is within the
range, I want to update the route number in table 2. There are multiple rows
in table 1 for each street name.

Both tables are quite - table 1 has 18,000 rows and table 2 has 500,000
rows.

Any suggestions would be greatly appreciated.


Making some assumptions about the fieldnames, I'd suggest trying a "non equi
join" query. This must be built in SQL, the query grid can't do it as a join:

UPDATE Table2
INNER JOIN Table1
ON Table1.Street = Table2.Street
AND Table1.LowNum = Table2.Address
AND Table1.HighNum = Table2.Address
SET Table2.Route = Table1.Route;

It's possible that the join won't be updateable; in that case you may need a
(less efficient) subquery:

UPDATE Table2
SET Route = (SELECT Table1.Route FROM Table1 WHERE Table1.Street =
Table2.Street AND Table1.LowNum = Table2.Address
AND Table1.HighNum = Table2.Address);

One question: street names aren't unique across jurisdictions. There's a
Franklin Road in Caldwell ID and a (different!!) Franklin Road in Nampa ID;
they're about five miles apart. Can you be sure that you don't have
ambiguities, where there are two different locations both identified as "123
Main St."?
--

John W. Vinson [MVP]
  #4  
Old March 5th, 2010, 01:38 AM posted to microsoft.public.access
Al
external usenet poster
 
Posts: 470
Default updating muliple rows in one table based on information in ano

John,

Your suggestion has gotten me on track...thanks for the help.

"John W. Vinson" wrote:

On Thu, 4 Mar 2010 10:39:02 -0800, Al wrote:

I have 2 access tables...table 1 contains a street name and a low number and
a high number as well as a route number. I wish to update table 2 which has
a row for each address. If the street matches and the address is within the
range, I want to update the route number in table 2. There are multiple rows
in table 1 for each street name.

Both tables are quite - table 1 has 18,000 rows and table 2 has 500,000
rows.

Any suggestions would be greatly appreciated.


Making some assumptions about the fieldnames, I'd suggest trying a "non equi
join" query. This must be built in SQL, the query grid can't do it as a join:

UPDATE Table2
INNER JOIN Table1
ON Table1.Street = Table2.Street
AND Table1.LowNum = Table2.Address
AND Table1.HighNum = Table2.Address
SET Table2.Route = Table1.Route;

It's possible that the join won't be updateable; in that case you may need a
(less efficient) subquery:

UPDATE Table2
SET Route = (SELECT Table1.Route FROM Table1 WHERE Table1.Street =
Table2.Street AND Table1.LowNum = Table2.Address
AND Table1.HighNum = Table2.Address);

One question: street names aren't unique across jurisdictions. There's a
Franklin Road in Caldwell ID and a (different!!) Franklin Road in Nampa ID;
they're about five miles apart. Can you be sure that you don't have
ambiguities, where there are two different locations both identified as "123
Main St."?
--

John W. Vinson [MVP]
.

  #5  
Old March 5th, 2010, 01:41 AM posted to microsoft.public.access
Al
external usenet poster
 
Posts: 470
Default updating muliple rows in one table based on information in ano

Hi Al,

Thanks for you assistance...the reply from John W. Vinson has set me on the
right track.



"Al Campagna" wrote:

Al,
Please give some sample/example values from each table, with field
names.
"This is what I have... vs... this is what I want."
Explain the logic you would use if you were to manually update the
second, from the first.
--
hth
Al Campagna
Microsoft Access MVP 2007-2009
http://home.comcast.net/~cccsolutions/index.html

"Find a job that you love... and you'll never work a day in your life."

"Al" wrote in message
...
I have 2 access tables...table 1 contains a street name and a low number
and
a high number as well as a route number. I wish to update table 2 which
has
a row for each address. If the street matches and the address is within
the
range, I want to update the route number in table 2. There are multiple
rows
in table 1 for each street name.

Both tables are quite - table 1 has 18,000 rows and table 2 has 500,000
rows.

Any suggestions would be greatly appreciated.



.

  #6  
Old March 5th, 2010, 10:44 PM posted to microsoft.public.access
r lonergan
external usenet poster
 
Posts: 2
Default updating muliple rows in one table based on information in ano



"Al" wrote in message
...
John,

Your suggestion has gotten me on track...thanks for the help.

"John W. Vinson" wrote:

On Thu, 4 Mar 2010 10:39:02 -0800, Al
wrote:

I have 2 access tables...table 1 contains a street name and a low number
and
a high number as well as a route number. I wish to update table 2 which
has
a row for each address. If the street matches and the address is within
the
range, I want to update the route number in table 2. There are multiple
rows
in table 1 for each street name.

Both tables are quite - table 1 has 18,000 rows and table 2 has
500,000
rows.

Any suggestions would be greatly appreciated.


Making some assumptions about the fieldnames, I'd suggest trying a "non
equi
join" query. This must be built in SQL, the query grid can't do it as a
join:

UPDATE Table2
INNER JOIN Table1
ON Table1.Street = Table2.Street
AND Table1.LowNum = Table2.Address
AND Table1.HighNum = Table2.Address
SET Table2.Route = Table1.Route;

It's possible that the join won't be updateable; in that case you may
need a
(less efficient) subquery:

UPDATE Table2
SET Route = (SELECT Table1.Route FROM Table1 WHERE Table1.Street =
Table2.Street AND Table1.LowNum = Table2.Address
AND Table1.HighNum = Table2.Address);

One question: street names aren't unique across jurisdictions. There's a
Franklin Road in Caldwell ID and a (different!!) Franklin Road in Nampa
ID;
they're about five miles apart. Can you be sure that you don't have
ambiguities, where there are two different locations both identified as
"123
Main St."?
--

John W. Vinson [MVP]
.

  #7  
Old March 13th, 2010, 05:46 PM posted to microsoft.public.access
De Jager
external usenet poster
 
Posts: 393
Default updating muliple rows in one table based on information in another


"Al" wrote in message
...
I have 2 access tables...table 1 contains a street name and a low number
and
a high number as well as a route number. I wish to update table 2 which
has
a row for each address. If the street matches and the address is within
the
range, I want to update the route number in table 2. There are multiple
rows
in table 1 for each street name.

Both tables are quite - table 1 has 18,000 rows and table 2 has 500,000
rows.

Any suggestions would be greatly appreciated.


  #8  
Old March 17th, 2010, 01:09 PM posted to microsoft.public.access
joelgeraldine
external usenet poster
 
Posts: 201
Default updating muliple rows in one table based on information in ano

y,,;;::!!!m!§!

"r lonergan" a écrit dans le message de groupe de
discussion : ...


"Al" wrote in message
...
John,

Your suggestion has gotten me on track...thanks for the help.

"John W. Vinson" wrote:

On Thu, 4 Mar 2010 10:39:02 -0800, Al
wrote:

I have 2 access tables...table 1 contains a street name and a low
number and
a high number as well as a route number. I wish to update table 2
which has
a row for each address. If the street matches and the address is
within the
range, I want to update the route number in table 2. There are multiple
rows
in table 1 for each street name.

Both tables are quite - table 1 has 18,000 rows and table 2 has
500,000
rows.

Any suggestions would be greatly appreciated.

Making some assumptions about the fieldnames, I'd suggest trying a "non
equi
join" query. This must be built in SQL, the query grid can't do it as a
join:

UPDATE Table2
INNER JOIN Table1
ON Table1.Street = Table2.Street
AND Table1.LowNum = Table2.Address
AND Table1.HighNum = Table2.Address
SET Table2.Route = Table1.Route;

It's possible that the join won't be updateable; in that case you may
need a
(less efficient) subquery:

UPDATE Table2
SET Route = (SELECT Table1.Route FROM Table1 WHERE Table1.Street =
Table2.Street AND Table1.LowNum = Table2.Address
AND Table1.HighNum = Table2.Address);

One question: street names aren't unique across jurisdictions. There's a
Franklin Road in Caldwell ID and a (different!!) Franklin Road in Nampa
ID;
they're about five miles apart. Can you be sure that you don't have
ambiguities, where there are two different locations both identified as
"123
Main St."?
--

John W. Vinson [MVP]
.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:57 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.