Click here to Skip to main content
15,747,169 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Experts
This is my issue

I am using vb6 and ms access
I have two table

Table name: Customer
id name count
1 A
2 B
3 C
4 D
count is null field here

Table name: Gold
custid gold
1 1
1 1
2 1
4 1

Here i want to update the count field in customer table with counting of gold.... Result should be like this

Table name: Customer
id name count
1 A 2
2 B 1
3 C 0 or null
4 D 1

Please help to solve..

What I have tried:

Googled a lot not found any solution..... plz help
Updated 9-Sep-18 7:28am
M4rLask 8-Sep-18 15:02pm    
Show us your code, use the "Improve question" widget to edit your question and provide better information.
Jörgen Andersson 8-Sep-18 15:39pm    
"Googled a lot not found any solution"
I wonder what you searched for then?
Try to google: "access update sql query from another table" and you will get several results that give you the info you need.
For example:
Both on the first page.

1 solution

Why do you want to update anything? Use simple join[^] instead:

SELECT, c.[name], SUM(g.[gold]) AS [CountOfGold]
FROM Customer AS C INNER JOIN Gold AS G ON = G.custid
GROUP BY, c.[name]

For further details, please see:
Visual Representation of SQL Joins[^]
SQL Aggregate Functions (SQL)[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900