>I want to find all id_2 that has same id_1 and time difference in
>records is no more than 5 minutes ...
How about ...
SELECT id_2
FROM tbl AS t1 JOIN tbl AS t2 ON t1.id_2 = t2.id_1
WHERE ABS(SEC_TO_TIME(t1.date_time)-SEC_TO_TIME(t2.date_time))<=300;
PB
-----
Peter wrote:
> Hello,
>
> Lets suppose I have a table like this one
>
> id id_1 id_2 date_time
> 1 101 1000 2006-07-04 11:25:43
> 2 102 1001 2006-07-04 11:26:43
> 3 101 1005 2006-07-04 11:27:43
> 4 103 1000 2006-07-04 11:25:43
>
> I want to find all id_2 that has same id_1 and time difference in
> records is no more than 5 minutes ...
>
> I hope I explain well
>
> In this case this is record 1 and record 3.
>
> How can I do this ?
>
> Thanks in advance for your help.
>
> Peter
> Send instant messages to your online friends http://uk.messenger.yahoo.com
>
>
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.408 / Virus Database: 268.13.4/478 - Release Date: 10/17/2006