×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Combining Queries

Combining Queries

Combining Queries

(OP)
Hi all,

I have the following tables and need to update data between them:

TableA

Desc PrevQty
abc
def
ghi
xyz

TableB

Desc Qty
abc 10
def 15
ghi 20
abc 30
xyz 10

I need help with a query to get the total Qty from tableB and update the PrevQty in TableA.

When the query is run, TableA should look like this:

TableA

Desc PrevQty
abc 40
def 15
ghi 20
xyz 10

so far I have this for the query:

SELECT Desc, sum(Qty) as TotalQty
FROM TableB
Group By Desc;

This obviously gives me the total qty for each desc - the trouble I am having is combining this with an update query to modify TableA - I hope I am half way there :)  There is every possibility that what I have started with is wrong!!

Any help or guidance offered is greatly appreciated.

Thanks
 

RE: Combining Queries

I'm not sure of the best ANSI SQL way to do this.  You'll probably have to to an update for each Desc.  If you tell me what database you're using, and what language interacts with  the database, I'll see what I can come up with for a solution.

-----------------------------------------
I cannot be bought.  Find leasing information at http://www.joshaxtell.com/

RE: Combining Queries

(OP)
Hi guys,

@jaxtell, I am using a MS Access database

@PHV, When you view the the query it gives a result which doesn't look as if it has consolidated the part numbers.  Although when you try to run the query it gives an error:
"Operation must use an updateable query"

Thanks for the help guys.

All help is greatly appreciated
Kind regards
Ota

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close