I've done some homework on this issue and I am pretty sure it will involve joining a table with itself but I'm not quite there yet.
I have a forum with a "posts" table. It stores the ipaddress, username, userid, and postid for every post made on the forum.
I am trying to get a query I can run each week or so that will output me a list of ipaddresses that have been used by multiple userids during this time- and the postids involved where the same ipaddress was used by multiple userids.
I've got this so far from other people's similar questions here:
SELECT t1.userid,t2.userid, t1.username, t2.username, t1.ipaddress, t2.ipaddress, t1.postid, t2.postid
FROM qvb_post t1
INNER JOIN qvb_post t2 ON t1.ipaddress=t2.ipaddress AND t1.userid!=t2.userid
WHERE
t1.dateline > 1335897698 AND t2.dateline > 1335897698
But it returns a lot of unnecessary rows IMO, fr example it returns each duplicate both ways- both as if userid 1 used userid 2's ipaddress and again as if userid2 used userid1's address.
The dateline is from a few days ago.
Ideally I'd like to just see a list of ip addresses in order with the duplicate usernames and repeated for each post, so I can go in with PHP and make a report that outputs an IP Address, the usernames (userids) that used it, and the postids created by them.
I am aware that there are many valid reasons two people will have the same ip address, rest assured no harsh action would be taken against anyone merely for showing up in this report.
Thank you in advance for any help you can provide.
Just to be clear I'm fine with the PHP, it's only the Query I need help with.