View Single Post
Old 12-08-2012, 09:47 PM   PM User | #5
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,210
Thanks: 59
Thanked 3,996 Times in 3,965 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Whoops...code does not work if one user makes more than one comment on a single itemid.

Nuts. It counts the user's own later posts.

Will think on it more.

The queryy is trivial for a single itemid and single userid.

For example:
Code:
mysql> select COUNT(*) FROM itemcomments AS C,
    ->   (SELECT Max(dateadded) AS lastcomment FROM itemcomments where itemid = 383 and userid = 100 ) AS M
    -> WHERE C.itemid = 383 AND C.userid <> 100 AND C.dateadded > lastcomment;
+----------+
| COUNT(*) |
+----------+
|        2 |
+----------+
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is online now   Reply With Quote