Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 13th, 2008, 09:55 AM
Authorized User
 
Join Date: Jul 2004
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old May 13th, 2008, 02:10 PM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
  #3 (permalink)  
Old May 14th, 2008, 11:04 PM
Authorized User
 
Join Date: Jul 2004
Location: , , .
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.

Reply With Quote
  #4 (permalink)  
Old May 15th, 2008, 06:38 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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. amit_mande@yahoo.com 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



All times are GMT -4. The time now is 05:19 AM.


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