473,379 Members | 1,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

How to join tables in Ma access

Hi, i have two tables that i wish to join. from the items table and purchases table, i use a query to list all the purchases for the day. then using sum i get all the amount used to purchase.my problem lies with getting a report that show purchases list with item name on each row. e.g 'cocaloa with its totals' and 'fanta' with its totals on the second row of the report.so how do i use sql to join cocacola and fanta total-purchases tables?
Jun 21 '10 #1

✓ answered by patjones

Can you provide more information about each of the tables? I'm thinking table names, as well as the names of the important columns, and maybe a few lines of sample data from each table. Thanks.

Pat

7 1790
patjones
931 Expert 512MB
Can you provide more information about each of the tables? I'm thinking table names, as well as the names of the important columns, and maybe a few lines of sample data from each table. Thanks.

Pat
Jun 21 '10 #2
Thanks for your concern, i really apreciate. here are the tables.one is 'Fanta-openingstock' and the other is 'Coke-openingstock'. all this tables were created from aquery called purchases. fields in 'Fanta table' are 1.[Item ID] 2.Name 3. [units-purchased] 4. [purchase price].
and 'coke-openingstock' has the folloing, 1.[Item ID ]2.[Name ]3.[Units-purchased] 4. [Purchase price]. i want after joining the two tables, opening stock for each should appear like SUM of '[units-purchased]*[purchase price]' as [opening stock]. i kindly hope u will understand my concept though i,m really a newbie in these. regards.
Jun 22 '10 #3
FishVal
2,653 Expert 2GB
1. Do you mean table join or table union?
2. Why do you have two separate tables?
Jun 22 '10 #4
patjones
931 Expert 512MB
As FishVal says, because these two tables have exactly the same data, they can be combined into one table.

As for the SUM that you want to do, are you saying that you want a single sum for Fanta, and a single sum for Coke? This is a fairly straightforward matter of calculating [Units-purchased]*[Purchase price] for each record, then summing over each record for Fanta and Coke respectively. This can be done nicely with SQL once we clarify the situation with your tables as FishVal suggests.

Pat
Jun 22 '10 #5
FishVal
2,653 Expert 2GB
Just to add to what Pat has said:

This combined table should have an additional field indicating whether a record is for Coke or Fanta. This field should be a FK of a master table. To get an idea of how data should be stored in relational database please read Database Normalization and Table Structures article.
Jun 22 '10 #6
Thanks again fishval and Pat. this is the cenario here, the two tables mentioned are made out of queries not real tables. otherwise cocacola and fanta belong to products table. what i want to achieve at the end of the day is totals for each product sold. below in the first sample is the query result for daily sales details. the second sample is where i was trieng to sum [units sold]*[unit sale price] to get totals but it results in error message. kindly assist. regards gerry.


SELECT [DAILY SALES].[ITEM ID], ITEMS.Name, [DAILY SALES].[UNITS SOLD], [DAILY SALES].[SALE PRICE], [DAILY SALES].[SOLD BY], [DAILY SALES].[DATE OF SALE], [DAILY SALES].[REVC ID]
FROM [DAILY SALES] INNER JOIN ITEMS ON [DAILY SALES].[ITEM ID]=ITEMS.[Item ID]
WHERE ((([DAILY SALES].[ITEM ID]) Like [ENTER ITEM CODE:] & "*") AND (([DAILY SALES].[DATE OF SALE]) Like [ENTER SALE DATE:] & "*"));




SELECT [DAILY SALES].[ITEM ID], ITEMS.Name, [DAILY SALES].[UNITS SOLD], [DAILY SALES].[SALE PRICE], [DAILY SALES].[SOLD BY], [DAILY SALES].[DATE OF SALE], [DAILY SALES].[REVC ID], SUM([UNITS SOLD]*[DAILY SALES].[SALE PRICE])
FROM [DAILY SALES] INNER JOIN ITEMS ON [DAILY SALES].[ITEM ID] = ITEMS.[Item ID]
WHERE ((([DAILY SALES].[ITEM ID]) Like [ENTER ITEM CODE:] & "*") AND (([DAILY SALES].[DATE OF SALE]) Like [ENTER SALE DATE:] & "*"));
Jun 25 '10 #7
patjones
931 Expert 512MB
So, to be clear, the first one runs, but the second one errors out?

I'm also still not clear on exactly what you're looking for. Do you just want a total for each item, or a total broken down by date, or a total broken down by who made the sales?

In the most general terms, it looks like you will want to use a GROUP BY in this query in order to get the proper sums that you are looking for. But I would need you to be more specific about what you want before I could advise you. Perhaps you can post a little sample of the sort of output you want...

Pat
Jun 25 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Daniel Rossi | last post by:
Hi there i am trying to work out the most efficient way to list say multipl= e categories of entries, the database is quite large about 200 meg.=20 I would like to know if using join tables is...
2
by: HS Hartkamp | last post by:
Hi all, I have a table with analysis-results for various months. An item can -for a particular month- have the result 'list1', 'list2' or 'list3' depending on the result of the analysis. ...
2
by: MLH | last post by:
The arduous job of importing Access 2.0 objects is complicated by the fact that I have some of the apps secured. I know I can UNSECURE chosen apps and circumvent this issue using the old...
2
by: zwasdl | last post by:
I'm using access to connect to Oracle via ODBC. I can also connect to Oracle via sql*plus. Can I write a query to join tables from different schema? If so, how? Thanks a million! Wei
1
by: 555 | last post by:
I would like to join MS Access table with Sybase table and retrieve some data. Could you please help me in how to code this in MS Access?
2
by: =?Utf-8?B?VGVycnk=?= | last post by:
Is it possible to join tables from different databases? If so, what is the format of the select statement? Both databases are on the same server. TIA, -- Terry
1
by: rneydr6034 | last post by:
MS Access I have an Access application that links to an Oracle database through ODBC. I need to join Access table and Oracle table. I wrote a query and when I try to run it it is asking me for...
21
patjones
by: patjones | last post by:
Hi all: My newest project involves creating a small help desk database for our customer service division to use. What will happen is that an employee will call up, explain his/her issue, and...
5
by: Amit Kumar M | last post by:
Which one is better way to join tables in SQL ? SELECT * FROM TABLE1, TABLE2 WHERE TABLE1.KEY = TABLE2.VALUE OR SELECT * FROM TABLE1 INNER JOIN TABLE2 ON TABLE1.KEY = TABLE2.VALUE Although...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.