SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Jan 2005
    Posts
    425
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Complex (for me) query help.

    I'm trying to modify an existing query to count mails sent today by member_id1 to member_id2 (unique) that are NOT replies to an existing message from member_id2 (reply time frame of 7 days).

    Replies are just based on the "subject" field, if the Subject is the same it is considered a reply.

    The existing query is rather simple:
    SELECT * FROM messages WHERE member_id1=8 AND senddate>=" . mktime(0, 0, 0) . " AND senddate>= " . mktime(23, 59, 59) . " GROUP BY member_id2
    This just counts the unique members that member 8 has messaged today.

    member_id1 is the sender
    senddate is int(10)
    subject is the Subject field - not used in the above query - but it determines if it is a reply.

    Any help with this would be greatly appreciated. I hope it makes sense.

  2. #2
    SitePoint Addict
    Join Date
    Sep 2005
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just change your GROUP BY

    GROUP BY member_id2, subject
    PHP Shopping Cart Software Easy Ecommerce Shopping Cart Script.
    PHP Super Cart is 100% template driven.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •