[EMAIL PROTECTED] wrote:

Problem: Spam Abuse
IP of offender: 66.50.xxX.245
Date of offense: 2004-07-05
Time of offense: 16:15

Now if I query the database based on date and ip address, I get the
following:
Id Date Time Record Type Full
Name IP Address
====== ==== ============ ============ ============
=========================


349         2004-07-05    11:21:08      Start         [EMAIL PROTECTED]
66.50.xxX.245
345         2004-07-05    11:21:09      Start         [EMAIL PROTECTED]
66.50.xxX.245
413         2004-07-05    11:22:32      Stop          [EMAIL PROTECTED]
66.50.xxX.245

[...]

a time data type. What I need to be able to do is find the start before
the offense time, and the stop after the offense time so I know that the
person with the start and the stop is the one that committed the abuse.



what a about the very simple approach?
This should be very fast if you habe indexes on ip, date, time and record_type.


select * from table where ip="1.1.1.1" and datefield="2004-07-05" and timefield<="16:15:00" and record_type="Start" order by timefield desc limit 1;
select * from table where ip="1.1.1.1" and datefield="2004-07-05" and timefield>="16:15:00" and record_type="Stop" order by timefield limit 1;




--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to