473,387 Members | 1,456 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,387 software developers and data experts.

Access multiplies my query count by 38... why?

ID - InputID

1 - data1
2 - data2
3 - data2
4 - data2
5 - data6
If I run a query that produces the count of each data input:
Expand|Select|Wrap|Line Numbers
  1. SELECT First(InventoryData2.InputID) AS FirstOfInputID, Count(InventoryData2.InputID) AS InputItemCount FROM InventoryInputT, InventoryData2 GROUP BY InventoryData2.InputID HAVING (((Count(InventoryData2.InputID))>=1)); 
Which, based on the data, SHOULD provide something along the lines of

data1: 1

data2: 3

data3: 1

HOWEVER, access shows my count totals as:

data1: = 38

data2: = 114

data3 = 38

ANY IDEA WHY?
May 2 '17 #1

✓ answered by Seth Schrock

When there is no join specified between the tables, then it ends up multiplying the record counts, so I'm guessing that you had 19 records in one table and 2 in the other. If you specify a join field (primary key/foreign key match), then it will match records together.

3 812
I was informed on another forum that the issue arrised from the SQL code that contained "FROM InventoryInputT, InventoryData2"... that effectively compared ALL rows from both tables and presented the data.

Removing the InventoryInputT from that FROM search fixed the issue!
May 2 '17 #2
Seth Schrock
2,965 Expert 2GB
When there is no join specified between the tables, then it ends up multiplying the record counts, so I'm guessing that you had 19 records in one table and 2 in the other. If you specify a join field (primary key/foreign key match), then it will match records together.
May 2 '17 #3
NeoPa
32,556 Expert Mod 16PB
For a fuller explanation look up "Cartesian Product" as that's the result when including two tables without specifying any type of JOIN.

NB. It's well worth remembering that you can have the same issue, that you refer to as multiplying, when multiple tables are joined together with specific JOIN types. How this area works should be properly understood before use if you hope to avoid such confusion in future.
May 3 '17 #4

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

Similar topics

1
by: Jack | last post by:
Hi, I am working on a asp page where I am opening a recordset object using an Access stored query named "GMISExpenseCombo". I have to use this resultset with various fields in the page. Howeve,r...
3
by: Matthias Haffke | last post by:
Ok, this is a tricky question for the pro's: My access sheet: line, id a, id b, val% ---------------- 1, a, ac, 0.04 2, a, ac, 0.28 3, a, ac, 0.015 4, a, ac, 0.205
1
by: Dman | last post by:
MS Access 2002 - query form control returns funny symbols like I am running an append query on a form. Access is having trouble with the calculated fields and comboboxes. Example – referring...
2
by: Greg Busby | last post by:
I'm trying to get an Access Crosstab query to fill a VB.NET datagrid. I'm getting an error that states "not a valid file name".. the query runs fine when I run the same SQL in Access. Can a...
1
by: Eglute | last post by:
Hello I want to show the results of MS Access database query in Visual basic. Do you know how to do this? I want to show the results in objects such as label or text box. Please help me. My code is:...
1
by: gazsharpe101 | last post by:
Hi, I have a problem which should have a relatively simple solution, I just cannot find it. I have a select query which gives me the following results: Company_Name Staff_FirstName ...
6
by: bobh | last post by:
Hi All, I'm looking for help with what the Transact SQL code is for this Access Update query sql code. I've been doing Access for some time and all my back-ends have been jet. I'm just starting...
2
by: CharlieUK | last post by:
I have a button on a Client form that opens a form with a query as filter. If the query filters no records then the form comes up blank and doesnt even show the close button. Im trying to use code to...
2
by: Michael Burke | last post by:
Access 2007 Query - how to open forms in Datasheet View rather than Form View on a Switchboard. I need to change the code in the code element named "HandleButtenClick" Yet I cannot find this code...
3
by: time2hike | last post by:
Hi, I have a query that pulls in hours for multiple Subprojects by Month and Year. To be able to compare data I need to Count the Month & Year for each subproject. Example Subproject1 11/2011 would...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.