UPDATE statement with subquery

Posted on 2008-10-28
Last Modified: 2010-08-05
I have the following query and when I try to execute it I get a message of You have written a subquery that can return more than one field without using the EXISTS reserved work in the main querys from clause.   I'm using Microsoft Access and am not sure how to revise the query.  Any help would be greatly appreciated.  I'm using Microsoft Access 2003.


update caserecords b
set unithours  = (select caseid, sum(casehours) as hours, int(sum(casehours)/60)&":"& (sum(casehours) mod 60)   as total_time from contactevents a
where = a.caseid
group by caseid)

Open in new window

Question by:lfolku
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
  • 4
  • 2
LVL 11

Expert Comment

ID: 22825341
You have set unithours  = followed by several fields.  Access thinks you are trying to assign multiple values to the unnithours field.
LVL 11

Expert Comment

ID: 22825390
I think you meant to do something like this:

UPDATE caserecords AS b LEFT JOIN contactevents AS a USING
SET b.unithours = int(sum(a.casehours)/60)&":"& (sum(a.casehours) mod 60)

This is very complex though, you might want to try setting a simpler value to make sure the other syntax is correct first.
LVL 11

Accepted Solution

miqrogroove earned 250 total points
ID: 22825402
Oops the USING term is not correct..

UPDATE caserecords AS b LEFT JOIN contactevents AS a ON
SET b.unithours = int(sum(a.casehours)/60)&":"& (sum(a.casehours) mod 60)
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.


Author Comment

ID: 22825480

I get a syntax error (missing operator) in query expression  'int(sum(a.casehours)/60)&":"& (sum(a.casehours) mod 60)

LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 250 total points
ID: 22825959
what about thius:
LVL 11

Expert Comment

ID: 22826197
I can't get Jet to eat a multi-table update command.  Try angellll's idea, and if that doesn't work we can write a query loop.

Author Closing Comment

ID: 31515918
Thanks for your help.

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

726 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