Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 13th, 2008, 09:55 AM
Authorized User
 
Join Date: Jul 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default Query help

I am relatively new at access queries - and I wnated toknow if this is possible to be done with a query (join) and if so how....

I have 3 tables - a table with a list of users
a table with a list of books
and a third table (relational table) with a list of user numbers and book numbers based on the books the user selected to read
(a user can pick more then one book and a book can be selected more then once...)

I wanted to know if a query could be created that would give me a the complete list of books along with a count which tells me how many times the book is found on the third table (how many people selected that book to read...) so if two people wanted to read that book there would be a 2 count and if no one choose to read that book there would be a 0 count ?

is this possible in one query? How would be the most efficient way to achieve this list of info?

thank you for your help

Elladi

 
Old May 13th, 2008, 02:10 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You would want to do this in the Query designer if you are new to SQL.

Open the query designer and select two tables, the Books table, and the selection junction table. The relationship between the tables should be visible between the two tables.

On the text menu, select View > Totals.

Select the Book Name field in the books table, then select the ID field in the junction table. Change the Total for this field to Count.

Select the relationship between the two tables, and check the check box that says "Show all records in the book table, and only those records in the junction table..."

When you run this query, it will show all the books, and then give you a count for all the times the book was selected. If the book was never selected, the field will be Null, and not have a 0 in it.

I know there is a way to add the 0, but I am not in front of Access right now.

Did that help?

mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old May 14th, 2008, 11:04 PM
Authorized User
 
Join Date: Jul 2004
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you I just got the query to work - it is perfect...by the way there is a 0 in the count field.

 
Old May 15th, 2008, 06:38 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

That's great about the 0. I thought it might not show up in ANSI 89.

mmcdonal

Look it up at: http://wrox.books24x7.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Output Query to txt file from SQL Query everest SQL Server 2005 4 November 22nd, 2007 01:49 AM
how to make a query from an existing query raport SQL Language 3 November 13th, 2006 08:59 PM
I solved insert query.now see this Update Query. [email protected] VB.NET 2002/2003 Basics 2 September 21st, 2006 12:48 AM
Syntax error in query. Incomplete query clause. dispickle ADO.NET 3 April 16th, 2004 01:04 PM
Error on Make-Table Query In Union Query rylemer Access 1 August 20th, 2003 07:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.