Log in

View Full Version : Help with query



Slicemahn
02-27-2008, 03:11 AM
Hello Everyone!

I am looking for some help in writing a query. I have two tables:

tblMarketingProgram

pkMarketingID
DateRequested
ProgramName
ProgramLaunchDate
ProgramEndDate

tblPhone

pkPhoneID
Phone
Status (ie. Eligible, Assigned, Active, Shutdown, Expired)
Platform
fkMarketingID
DateStamp

I am querying the table to find all new records in the Marketing table that have yet to be assigned. So my SQL is the following:

SELECT tblMarketingProgram.pkProgramID, tblMarketingProgram.DateRequested, tblMarketingProgram.ProgramName, tblMarketingProgram.ProgramLaunchDate, tblMarketingProgram.ProgramEndDate, tblMarketingProgram.Active
FROM tblMarketingProgram INNER JOIN tblPhone ON tblMarketingProgram.pkProgramID = tblPhone.fkProgramID
WHERE (((DateDiff("d",[TimeofEntry],Date()))<5));

Now to further narrow things down, I would add the criteria of the pkProgramID does not already exist or show in the Phones table?

OBP
02-27-2008, 10:37 AM
If you just link the tables in the query and then in the Criteria Row of the Status put in "Eligible" if that denotes that the program is eligible but not active.
Is taht what you mean?