Posted by J.O. Aho on 11/20/06 09:12
flouger@gmail.com wrote:
> Im trying to write the following query to do the following but im not
> sure about the right way to do it
>
> I want to get back all the results minus any results that are within
> the 3 minutes of each other containing the same ip address, and same
> owner information.
>
> Basicly I want to filter out multiple entries with different times.
>
> the database looks like this.
> `owner` int(11) NOT NULL default '0',
> `visitor` int(11) NOT NULL default '0',
> `visittime` timestamp(14) NOT NULL,
> `ip` varchar(16) NOT NULL default ''
>
> I Imagine I need to use a time diff function but am not really sure how
> to implement that in.
I would make a sql function/procedure that takes visittime to a time with 3
mins steps
http://dev.mysql.com/doc/refman/5.0/en/create-procedure.html
Then you apply that to the visittime column and make a DISTINCT select and you
should get quite close to what you had in mind.
//Aho
[Back to original message]
|