MySQL查询日期,两个日期字段之间

问题描述:

我正在使用MySql 5.5.

I'm using MySql 5.5.

我需要找到一个具有特定IP地址的日期的用户ID.

I need to find a userid on a date with a particular ip address.

这些字段是用户ID,ip地址,开始日期,结束日期.

The fields are userid, ipaddress, startdate, enddate.

例如,我正在寻找2011年9月12日IP地址为192.168.1.1的用户ID.

So for instance I am looking for a userid with ip address 192.168.1.1 on Sep 12 2011.

查询将类似 select * from database where ipaddress='192.168.1.1' and 2011-12-09 is in(startdate and enddate);

欢迎指出此逻辑缺陷的任何帮助.谢谢.

Any help to pointing out this logic flaw is welcome. Thank you.

不清楚是否要:

'2011-12-09' BETWEEN startdate AND enddate

或:

'2011-12-09' = startdate AND '2011-12-09' = enddate