Home > Archive > PHP SQL > November 2006 > Mysql Query Question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Mysql Query Question
|
|
| flouger@gmail.com 2006-11-20, 3:58 am |
| 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.
Thanks
| |
| J.O. Aho 2006-11-20, 3:58 am |
| 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...-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
|
|
|
|
|