I am trying to create a page that displays all replies to first tier comments of the active user. Here is an example DB table similar to the one I have...
commentid | postid | commid | username | userid | commtext |
---|---|---|---|---|---|
52 | 100 | 0 | user1 | 1 | first |
53 | 100 | 52 | user2 | 2 | second |
54 | 100 | 52 | user1 | 1 | third |
"commentid" is the comment's unique id, "postid" is the id of the post it was on, "commid" gives the number of the comment that it was a response to ("0" indicates it is on the first tier), and so on...
If I am logged in as "user1" and I do the following...
$ra = $DB->Execute('SELECT * FROM comments WHERE userid = '.$DB->qstr($id).' ORDER BY commentid DESC')
...it will return comments #52 and #54. Simple enough.
I am having an issue creating a request to the DB that will output a list that gives me #53 (which was a reply to user1's comment). If possible, I do not want to include #54 which was written by the active user him/herself.
What would be a good way to construct this query?
'SELECT * FROM comments WHERE commid = 52 AND userid != '.$DB->qstr($id).' ORDER BY commentid DESC'
?