OK, This is for our mail script.
What is going on is the following.
We are dealing with 4 tables, to make this work.
What all this does.
Has joined any Sub-Categories, the UNIQUE ID for them will be stored in the Lists table
Tables, has a child called Media
When there are records in the Media Table.
Then an email is generated out to all people that are in the Lists table for the SubCategories.
Right now, I get 2 to 10 emails all duplicated, depending on the user.
So, what I need is the following.
Look through the table "AskUser
And only send out to the UNIQUE ID, ONE time.
Instead of multiple emails.
Here is the code that I have.
SELECT AskUser.askid, SubCategories.SubName, Media.MedName, Media.SCID, Media.MedID, Media.Closed, Media.MedDate
FROM AskUser INNER JOIN
Lists ON AskUser.askid = Lists.AskID INNER JOIN
Media ON Lists.SCID = Media.SCID INNER JOIN
SubCategories ON Media.SCID = SubCategories.SCID
(Media.Closed = 0) AND
(Media.MedDate > CONVERT(DATETIME, '2011-12-16 00:00:00', 102))
To add to this.
I also tried MIN
And they did not work in this case. Unless I am just not doing something right this early morning or late at night. 4:31am here, need rest :)