Hi, I have a Access database with two tables; a category table and an images
table. In the Category table I have a field for Index number and a field for
Categories. The images table has a field for all the images and a field to
specify what category the images are assigned to.
I am trying to write a simple Select query that will return a list of
Categories from my Category table, and in the second colum a count of the
number of images assigned to each category from my main table of images.
Can anybody suggest how I could do this?
Thanks for any help you can give me,
Mark. 5 4189
SELECT Categories.Name,
COUNT(Images.CategoryID)
FROM Categories INNER JOIN Images
ON Images.CategoryID = Categories.CategoryID
GROUP BY Categories.Name
-- http://www.aspfaq.com/
(Reverse address to reply.)
"Mark" <m@notmyemailaddress.com> wrote in message
news:Rm******************@stones.force9.net... Hi, I have a Access database with two tables; a category table and an
images table. In the Category table I have a field for Index number and a field
for Categories. The images table has a field for all the images and a field to specify what category the images are assigned to.
I am trying to write a simple Select query that will return a list of Categories from my Category table, and in the second colum a count of the number of images assigned to each category from my main table of images.
Can anybody suggest how I could do this?
Thanks for any help you can give me,
Mark.
Mark wrote: Hi, I have a Access database with two tables; a category table and an images table. In the Category table I have a field for Index number and a field for Categories. The images table has a field for all the images and a field to specify what category the images are assigned to.
I am trying to write a simple Select query that will return a list of Categories from my Category table, and in the second colum a count of the number of images assigned to each category from my main table of images.
Can anybody suggest how I could do this?
Thanks for any help you can give me,
Mark.
SELECT c.Categories, count(*)
FROM Category c inner join Images i
ON c.Categories = i.Categories
GROUP BY c.Categories
HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Thanks Aaron and Bob, its working now!
"Mark" <m@notmyemailaddress.com> wrote in message
news:Rm******************@stones.force9.net... Hi, I have a Access database with two tables; a category table and an
images table. In the Category table I have a field for Index number and a field
for Categories. The images table has a field for all the images and a field to specify what category the images are assigned to.
I am trying to write a simple Select query that will return a list of Categories from my Category table, and in the second colum a count of the number of images assigned to each category from my main table of images.
Can anybody suggest how I could do this?
Thanks for any help you can give me,
Mark.
Hi, I have one other quick question: if I wanted to include the ID field for
each category, would it just be a case of changing the SQL from:
SELECT Categories.Name,
COUNT(Images.CategoryID)
FROM Categories INNER JOIN Images
ON Images.CategoryID = Categories.CategoryID
GROUP BY Categories.Name
TO:
SELECT Categories.ID, Categories.Name,
COUNT(Images.CategoryID)
FROM Categories INNER JOIN Images
ON Images.CategoryID = Categories.CategoryID
GROUP BY Categories.Name
So far this has not worked and I get the error:
"You tried to execute a query that does not include the specified expression
'ID' as part of an aggregate function"
"Mark" <m@notmyemailaddress.com> wrote in message
news:Rm******************@stones.force9.net... Hi, I have a Access database with two tables; a category table and an
images table. In the Category table I have a field for Index number and a field
for Categories. The images table has a field for all the images and a field to specify what category the images are assigned to.
I am trying to write a simple Select query that will return a list of Categories from my Category table, and in the second colum a count of the number of images assigned to each category from my main table of images.
Can anybody suggest how I could do this?
Thanks for any help you can give me,
Mark.
Sorted it with this:
SELECT tblCategories.ID, tblCategories.CatName,
COUNT(tblImages.CategoryID)
FROM tblCategories INNER JOIN tblImages
ON tblImages.CategoryID = tblCategories.ID
GROUP BY tblCategories.CatName, tblCategories.ID
Thanks.....
"Mark" <m@notmyemailaddress.com> wrote in message
news:Rm******************@stones.force9.net... Hi, I have a Access database with two tables; a category table and an
images table. In the Category table I have a field for Index number and a field
for Categories. The images table has a field for all the images and a field to specify what category the images are assigned to.
I am trying to write a simple Select query that will return a list of Categories from my Category table, and in the second colum a count of the number of images assigned to each category from my main table of images.
Can anybody suggest how I could do this?
Thanks for any help you can give me,
Mark.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: krystoffff |
last post by:
Hi
I would like to paginate the results of a query on several pages. So I
use a query with a limit X offset Y to display X results on a page,
ok.
But for the first page, I need to run the...
|
by: Steven D.Arnold |
last post by:
I have a query which does not use column indexes that it should use. I
have discovered some interesting behaviors of Postgres which may
indicate a bug in the database's query planning.
Take a...
|
by: Nicolae Fieraru |
last post by:
Hi All,
I have a query, Select Count(BoolField) from tblMyTable, Where BoolField =
true.
If I run the query by itself, it returns the number of true records
I want to use the result of that...
|
by: Riley DeWiley |
last post by:
I am continually amazed by SQL's ability to humble me ....
I have a toy query into a toy database that looks just like this:
SELECT .
FROM f, fw, w
WHERE f.id = fw.fid and fw.wid = w.id and...
|
by: P B via AccessMonster.com |
last post by:
I have a list of 160,000 records with these fields:
fname, lname, address, city, state, zip, dob
I need to generate a list with all fields where the first initial of lname
and the dob are...
|
by: sunilkeswani |
last post by:
Hi
I am still new to access. I want to know how i can build a query which
can display results from 4 different columns/fields
Like.
Field1 Field2 Field3 Field4
1 2 1 ...
|
by: uspensky |
last post by:
I have a table (cars) with 3 fields:
VIN, Class, sell_price
101, sports, 10000
102, sports, 11000
103, luxury, 9000
104, sports, 11000
105, sports, 11000
106, luxury, 5000
107, sports, 11000
|
by: phlype.johnson |
last post by:
I'm struggling to find the best query from performance point of view
and readability for a normalized DB design.
To illustrate better my question on whether normalized designs lead to
more complex...
|
by: QCLee |
last post by:
Sir can you help me to transfer my Access Query to MS excel? i have a
command button on the form to export the parameter query named
"HVACWindwardQuery" to excel spreadsheet and i got the codes...
|
by: jameswilkinsonfjs |
last post by:
Hi All,
Ok I have a table - it lists items with a unique reference
code; lets say there are 4 items :
Item RefCode
1 ABC1
2 ABC2
3 ...
|
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,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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
|
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...
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |