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 » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

SQL - UPDATE statement help....



 
 
Thread Tools Display Modes
  #1  
Old October 2nd, 2006, 11:10 PM posted to microsoft.public.access.queries
awrex
external usenet poster
 
Posts: 47
Default SQL - UPDATE statement help....

update mailstops
set blgdid = (select bldgid from tblbldg)
where mailstops.bldg_abb = tblbldg.bldg

Can anyone tell me why I get a parameter pop window when I execute this?

Does SQL Jet UPDATE work the same as T-SQL UPDATE?

This is driving me crazy... I've looked up every instance of help for the
UPDATE statement and as to what the parameters are for it.

Thanks for your help!!
  #2  
Old October 3rd, 2006, 12:01 AM posted to microsoft.public.access.queries
awrex
external usenet poster
 
Posts: 47
Default SQL - UPDATE statement help....

nevermind.... I got it to work.. however not using the original statement....

Why did this work, with no pop up windows requesting parameters....

update mailstops right join tblbldg
on mailstops.bldg_app = tblbldg.bldg
set mailstops.bldgid = tblbldg.bldgid

and this didn't??
update mailstops
set blgdid = (select bldgid from tblbldg)
where mailstops.bldg_abb = tblbldg.bldg




"awrex" wrote:

update mailstops
set blgdid = (select bldgid from tblbldg)
where mailstops.bldg_abb = tblbldg.bldg

Can anyone tell me why I get a parameter pop window when I execute this?

Does SQL Jet UPDATE work the same as T-SQL UPDATE?

This is driving me crazy... I've looked up every instance of help for the
UPDATE statement and as to what the parameters are for it.

Thanks for your help!!

  #3  
Old October 3rd, 2006, 12:19 AM posted to microsoft.public.access.queries
John Vinson
external usenet poster
 
Posts: 4,033
Default SQL - UPDATE statement help....

On Mon, 2 Oct 2006 16:01:02 -0700, awrex
wrote:

nevermind.... I got it to work.. however not using the original statement....

Why did this work, with no pop up windows requesting parameters....

update mailstops right join tblbldg
on mailstops.bldg_app = tblbldg.bldg
set mailstops.bldgid = tblbldg.bldgid

and this didn't??
update mailstops
set blgdid = (select bldgid from tblbldg)
where mailstops.bldg_abb = tblbldg.bldg


It didn't work because you're referring to tblbldg - which is defined
only INSIDE the subquery - outside the parentheses. This should work:

update mailstops
set blgdid = (select bldgid from tblbldg
where mailstops.bldg_abb = tblbldg.bldg)

but the Right Join will be faster and more efficient.

John W. Vinson[MVP]

  #4  
Old October 3rd, 2006, 12:25 AM posted to microsoft.public.access.queries
mscertified
external usenet poster
 
Posts: 835
Default SQL - UPDATE statement help....

'tblbldg.bldg' cannot be resolved as it is outsiode the parentheses and
'mailstops.bldg_abb ' cannot be resolved since there is no FROM clause for
the mailstops table.

update mailstops
set blgdid = (select bldgid from tblbldg)
where mailstops.bldg_abb = tblbldg.bldg


"awrex" wrote:

nevermind.... I got it to work.. however not using the original statement....

Why did this work, with no pop up windows requesting parameters....

update mailstops right join tblbldg
on mailstops.bldg_app = tblbldg.bldg
set mailstops.bldgid = tblbldg.bldgid

and this didn't??
update mailstops
set blgdid = (select bldgid from tblbldg)
where mailstops.bldg_abb = tblbldg.bldg




"awrex" wrote:

update mailstops
set blgdid = (select bldgid from tblbldg)
where mailstops.bldg_abb = tblbldg.bldg

Can anyone tell me why I get a parameter pop window when I execute this?

Does SQL Jet UPDATE work the same as T-SQL UPDATE?

This is driving me crazy... I've looked up every instance of help for the
UPDATE statement and as to what the parameters are for it.

Thanks for your help!!

  #5  
Old October 3rd, 2006, 12:46 AM posted to microsoft.public.access.queries
awrex
external usenet poster
 
Posts: 47
Default SQL - UPDATE statement help....

Thanks for the reply.

Though one last follow up..

update mailstops
set blgdid = (select bldgid from tblbldg)
where mailstops.bldg_abb = tblbldg.bldg


This doesn't work because no table is defined correct? ie. no FROM clause.

So if I did this, is it supposed work?? I actually tried a bunch of
different statements to get this table updated, including the FROM clause and
would always get an error when I used it. I even tried the statement below
but nothing.

update mailstops
set blgdid = (select bldgid from tblbldg)
from mailstops, tblbldg
where mailstops.bldg_abb = tblbldg.bldg








"awrex" wrote:

nevermind.... I got it to work.. however not using the original statement....

Why did this work, with no pop up windows requesting parameters....

update mailstops right join tblbldg
on mailstops.bldg_app = tblbldg.bldg
set mailstops.bldgid = tblbldg.bldgid

and this didn't??
update mailstops
set blgdid = (select bldgid from tblbldg)
where mailstops.bldg_abb = tblbldg.bldg




"awrex" wrote:

update mailstops
set blgdid = (select bldgid from tblbldg)
where mailstops.bldg_abb = tblbldg.bldg

Can anyone tell me why I get a parameter pop window when I execute this?

Does SQL Jet UPDATE work the same as T-SQL UPDATE?

This is driving me crazy... I've looked up every instance of help for the
UPDATE statement and as to what the parameters are for it.

Thanks for your help!!

  #6  
Old October 3rd, 2006, 01:00 AM posted to microsoft.public.access.queries
Neil Sunderland
external usenet poster
 
Posts: 92
Default SQL - UPDATE statement help....

awrex wrote:
So if I did this, is it supposed work?? I actually tried a bunch of
different statements to get this table updated, including the FROM clause and
would always get an error when I used it. I even tried the statement below
but nothing.

update mailstops
set blgdid = (select bldgid from tblbldg)
from mailstops, tblbldg
where mailstops.bldg_abb = tblbldg.bldg


Try this:
UPDATE mailstops
SET blgdid =
(SELECT MIN(bldgid)
FROM mailstops, tblbldg
WHERE mailstops.bldg_abb = tblbldg.bldg)

--
Neil Sunderland
Braunton, Devon

Please observe the Reply-To address
  #7  
Old October 3rd, 2006, 01:05 AM posted to microsoft.public.access.queries
Neil Sunderland
external usenet poster
 
Posts: 92
Default SQL - UPDATE statement help....

Neil Sunderland wrote:
Try this:
UPDATE mailstops
SET blgdid =
(SELECT MIN(bldgid)
FROM mailstops, tblbldg
WHERE mailstops.bldg_abb = tblbldg.bldg)


No, don't try that - it won't work...

Try this instead:

UPDATE mailstops
SET blgdid =
(SELECT MIN(bldgid)
FROM tblbldg
WHERE mailstops.bldg_abb = tblbldg.bldg)

--
Neil Sunderland
Braunton, Devon

Please observe the Reply-To address
  #8  
Old October 4th, 2006, 09:37 PM posted to microsoft.public.access.queries
awrex
external usenet poster
 
Posts: 47
Default SQL - UPDATE statement help....

THANKS FOR YOUR HELP!!!

"Neil Sunderland" wrote:

Neil Sunderland wrote:
Try this:
UPDATE mailstops
SET blgdid =
(SELECT MIN(bldgid)
FROM mailstops, tblbldg
WHERE mailstops.bldg_abb = tblbldg.bldg)


No, don't try that - it won't work...

Try this instead:

UPDATE mailstops
SET blgdid =
(SELECT MIN(bldgid)
FROM tblbldg
WHERE mailstops.bldg_abb = tblbldg.bldg)

--
Neil Sunderland
Braunton, Devon

Please observe the Reply-To address

 




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:54 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.