The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Selecting records for today - Part 2

This is in reference to my original post, which has been moved to PHP - I didn't realise until too late:http://www.sitepoint.com/forums/showthread.php?t=648498
However this part is MySQL purely and NOT php.
********************************
ok guys. next part to the question, which is purely SQL not php related.

I want to count messages from user 8 where the recipient of the messages is unique between these date ranges - to see how many unique people they contacted.

2nd half- I would further like to refine the above, to only count the times the unque person replied - but this part is over my head.
Eg.
if "user id: 1" contacts "user id: 2" 10 times and "user id: 2" replies ( once or more ) = 1 successful contact attempt

So far I got:
SELECT count(DISTINCT messages.to) FROM messages WHERE messages.from = 8 and messages.sent >= 1258927200 and messages.sent <= 1259013599
But that only counts unique attempts (successful and failed contact attempts), not just successful attempts.

No results (0 records), until I delete "AND mreply.sent > mfrom.sent AND mreply.sent <= 1259013599". If I delete this I get a result, but even if the "reply" was from an earlier period, which is wrong.

In the perspective of "WHERE mfrom.FROM = 8" should be 1 (because the message from 17 was after (but in the same day) as the message from 8)
In the perspective of "WHERE mfrom.FROM = 17" should be 0 (because the message from 8 was before the message from 17)