PC Review


Reply
Thread Tools Rate Thread

Convert SELECT to UPDATE query

 
 
SinCity
Guest
Posts: n/a
 
      15th Jan 2007
I am trying to convert this SELECT query into an UPDATE query...

SELECT Left([BFirstName2],InStr([BFirstName2]," ")) AS BFirstName,
Mid([BFirstName2],InStr([BFirstName2]," ")+1) AS BLastName
FROM [77777 Show];

I tried simply replacing SELECT with UPDATE which is what I thought was
needed to be done. What am I missing?

What I am trying to do is UPDATE the data in table 77777 with the results of
the SELECT query.

Help!


 
Reply With Quote
 
 
 
 
Van T. Dinh
Guest
Posts: n/a
 
      15th Jan 2007
No ... you need the SET Clause in the UPDATE Query like

UPDATE [MyTable]
SET [MyField] = [Myfield] * 2

(meaning doubling the value of [MyField])

--
HTH
Van T. Dinh
MVP (Access)



"SinCity" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I am trying to convert this SELECT query into an UPDATE query...
>
> SELECT Left([BFirstName2],InStr([BFirstName2]," ")) AS BFirstName,
> Mid([BFirstName2],InStr([BFirstName2]," ")+1) AS BLastName
> FROM [77777 Show];
>
> I tried simply replacing SELECT with UPDATE which is what I thought was
> needed to be done. What am I missing?
>
> What I am trying to do is UPDATE the data in table 77777 with the results
> of the SELECT query.
>
> Help!
>



 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      15th Jan 2007
UPDATE [77777] INNER JOIN [77777 Show]
ON [77777].ID = [77777 Show].ID
SET BFirstName = Left([77777 Show].[BFirstName2],InStr([77777
Show].[BFirstName2]," "))
BLastName = Mid([77777 Show].[BFirstName2],InStr([77777
Show].[BFirstName2]," ")+1)

This assumes that the Primary Key for both tables is named ID. You'll have
to fuss with the ON clause if that's not the case.


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"SinCity" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I am trying to convert this SELECT query into an UPDATE query...
>
> SELECT Left([BFirstName2],InStr([BFirstName2]," ")) AS BFirstName,
> Mid([BFirstName2],InStr([BFirstName2]," ")+1) AS BLastName
> FROM [77777 Show];
>
> I tried simply replacing SELECT with UPDATE which is what I thought was
> needed to be done. What am I missing?
>
> What I am trying to do is UPDATE the data in table 77777 with the results
> of the SELECT query.
>
> Help!
>



 
Reply With Quote
 
SinCity
Guest
Posts: n/a
 
      15th Jan 2007
news:(E-Mail Removed)...
> UPDATE [77777] INNER JOIN [77777 Show]
> ON [77777].ID = [77777 Show].ID
> SET BFirstName = Left([77777 Show].[BFirstName2],InStr([77777
> Show].[BFirstName2]," "))
> BLastName = Mid([77777 Show].[BFirstName2],InStr([77777
> Show].[BFirstName2]," ")+1)
>
> This assumes that the Primary Key for both tables is named ID. You'll have
> to fuss with the ON clause if that's not the case.


Thanks so much Doug. I tried your suggestion but got the following error...

"Syntax Error in JOIN Operation".

Here is my exact code. Note that I changed the name of the table from "7777
Show" to "73106".

UPDATE [73106] INNER JOIN [73106]
ON [73106].ID = [73106].ID
SET BFirstName = Left([73106].[BFirstName2],InStr([73106].[BFirstName2],"
"))
BLastName = Mid([73106].[BFirstName2],InStr([73106].[BFirstName2]," ")+1)

Any idea what is wrong?


 
Reply With Quote
 
Van T. Dinh
Guest
Posts: n/a
 
      15th Jan 2007
Since you have only 1 Table, you don't need the join. try:

========
UPDATE [73106]
SET BFirstName = Left( [BFirstName2], InStr([BFirstName2]," ") ),
BLastName = Mid( [BFirstName2], InStr([BFirstName2]," ")+1 )
========


--
HTH
Van T. Dinh
MVP (Access)



"SinCity" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks so much Doug. I tried your suggestion but got the following
> error...
>
> "Syntax Error in JOIN Operation".
>
> Here is my exact code. Note that I changed the name of the table from
> "7777 Show" to "73106".
>
> UPDATE [73106] INNER JOIN [73106]
> ON [73106].ID = [73106].ID
> SET BFirstName = Left([73106].[BFirstName2],InStr([73106].[BFirstName2],"
> "))
> BLastName = Mid([73106].[BFirstName2],InStr([73106].[BFirstName2]," ")+1)
>
> Any idea what is wrong?
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Combining a Select query and an Update query =?Utf-8?B?SmFhcCBIYXJ0b2c=?= Microsoft Access Queries 1 9th Jul 2007 03:42 AM
Error msg when convertint a select query in to an update query =?Utf-8?B?U3RldmUgUw==?= Microsoft Access Queries 2 20th Feb 2007 05:28 PM
Can an update query return a calculated value to a select query? =?Utf-8?B?Q2RuUm94?= Microsoft Access Queries 2 3rd May 2006 03:25 PM
To change a select Query to an update Query =?Utf-8?B?bWF1ZDAzNjE=?= Microsoft Access Queries 2 18th Nov 2005 12:48 AM
Update Query Finds Different Number of Records Than Select Query mjbigelow@gmail.com Microsoft Access Queries 2 21st Jul 2005 09:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:14 AM.