Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

== Trouble writing a query ==

Status
Not open for further replies.

Lynux

MIS
Aug 3, 2001
33
US
I have a table of "activities" and a table of "user_activities".... once a user completes an activity in the "activities" table and logs that in on our web site it shows up as a completed task... here is the query that is used:
==========================>

Select fname, lname, user_activities.activities_ID, activities.description
from users, user_activities, activities where users.pin = 5099 AND user_activities.PIN = 5099 AND
user_activities.activities_ID = activities.ID

====================================================
The big question is... How do I query the table "activities" using the table "user_activities" to show all of the activities that the user has not completed yet? I tried the obviouse Query:
=======================>

Select fname, lname, user_activities.activities_ID, activities.description
from users, user_activities, activities where users.pin = 5099 AND user_activities.PIN = 5099 AND
user_activities.activities_ID <> activities.ID

======================================================

That was the furthest thing from the output I was looking for........... Anyone have any suggestions?
If you can answer this one you got my vote! :)

Thanks a ton in advance! =================================
Imagination is more important than knowledge.
(A.E.)
 
Check out Access help for the Find Unmatched Query Wizard. This should be what you're looking for.....
 
If you will explain to me your table layout a little more I can probably help you. Tell me if I'm on the right track.

Is your table 'activities' a list of possible activities that can be completed by a user, with a primary key called 'ID'?

Is table 'user_activities' a list of actual activities completed by users? I don't think you listed the primary key to this one.

Table 'users' is a list of users that uses 'pin' as the primary key to the field.

Then I'm guessing in 'user_activities' you have two foreign keys to the 'activities' and 'users' tables with the keys of 'PIN' and 'activities_ID'?

So there is a one(users)-to-many(user_activities) relationship and a one(activities)-to-many(user_activities) relationship correct?

I'm not sure if your wanting a list of the activities completed by a specific user or a list of the items from 'activities' that there isn't an entry for in 'user_activities' for the selected user?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top