?
Solved

Access question - SELECT/UPDATE

Posted on 2016-10-05
11
Medium Priority
?
63 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 29

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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 29

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 29

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 29

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
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…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Suggested Courses

800 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