?
Solved

Access question - SELECT/UPDATE

Posted on 2016-10-05
11
Medium Priority
?
66 Views
Last Modified: 2016-10-06
How can I do this using Access SQL:

update work_order set local_service_order_id = (select local_Id from service_order where id = 7525) where  service_order_id = 7525
0
Comment
Question by:HLRosenberger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
11 Comments
 
LVL 22

Assisted Solution

by:Kelvin Sparks
Kelvin Sparks earned 1000 total points
ID: 41830837
UPDATE work_order, service_order set local_service_order_id = Service_Order.Local_ID
WHERE work_Order.service_order_id = 7525 and service_order.id = 7525

Kelvin
0
 
LVL 32

Expert Comment

by:Pawan Kumar
ID: 41830921
UPDATE w
set w.local_service_order_id = so.Local_ID 
FROM work_order w
INNER JOIN service_order so ON so.Local_ID = w.local_service_order_id
WHERE w.service_order_id = 7525 and so.id = 7525

Open in new window

0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 41831628
that gives me an error.

  SQL error
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 32

Expert Comment

by:Pawan Kumar
ID: 41831631
Please try this..

UPDATE work_order
set work_order.local_service_order_id = service_order.Local_ID
FROM work_order
INNER JOIN service_order ON service_order.Local_ID = work_order.local_service_order_id
WHERE work_order.service_order_id = 7525 and service_order.id = 7525
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 41831655
that too gives me the same syntax error.
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 41831660
Kelvin - your SQL worked. Now how do I make it generic so that it updates for all values of xxx, where  work_Order.service_order_id = service_order.id

UPDATE work_order, service_order set local_service_order_id = Service_Order.Local_ID
 WHERE work_Order.service_order_id = xxx and service_order.id = xxx
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 41831663
ah, this works:

UPDATE work_order, service_order set local_service_order_id = Service_Order.Local_ID
  WHERE work_Order.service_order_id = service_order.id

right?
0
 
LVL 32

Accepted Solution

by:
Pawan Kumar earned 1000 total points
ID: 41831664
try this..to update all values.. (Make sure you have backup of the table you are updating.)

UPDATE work_order, service_order set local_service_order_id = Service_Order.Local_ID WHERE work_Order.service_order_id = service_order.id
0
 
LVL 32

Expert Comment

by:Pawan Kumar
ID: 41831666
Great !!!
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 41831766
Thanks!
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 41831771
Thanks!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question