Say i have this table:
+----+------+---------------------+-------------------------+
| id | user | timestamp | referrer |
+----+------+---------------------+-------------------------+
| 1 | foo | 2012-08-26 14:05:55 | http://fubar.com/online |
+----+------+---------------------+-------------------------+
| 2 | foo | 2012-08-26 14:05:59 | http://fubar.com/chat |
+----+------+---------------------+-------------------------+
| 3 | bar | 2012-08-27 07:06:07 | http://fubar.com/chat |
+----+------+---------------------+-------------------------+
| 4 | max | 2012-08-28 14:08:12 | http://fubar.com/chat |
+----+------+---------------------+-------------------------+
| 5 | max | 2012-08-28 14:08:36 | http://fubar.com/online |
+----+------+---------------------+-------------------------+
i want to select all users who has both more than 1 referrer and timestamps are the same up to the minute precision
this would mean that during a span of 1 minute, they were viewing 2 pages of the same site and thus could imply that they are multi-tabbing. so in the table above, foo and max would fit the criteria.
i want to know how i can achieve this in mysql.
thank you.
Make a self-join and use
TIMESTAMPDIFF()in the join cirteria:See it on sqlfiddle.