不显示与上次日期相关的数据

时间:2012-10-12 12:45:19

标签: mysql

以下是查询

SELECT
users.userName,
rechannel.channelName,
trschedule.ContentType,
trprogram.programName,
trschedule.Description,
trschedule.startTime,
trschedule.endTime,
TIMEDIFF(trschedule.startTime,trschedule.endTime) AS Difference,
LENGTH(trschedule.Description) AS Charcter_Count,
ROUND( LENGTH(trschedule.Description)/6) AS Word_Count,
ROUND( LENGTH(trschedule.Description)/65) AS Line_Count,
trschedule.ProvinceName,
trschedule.CityName,
trschedule.AreaName,
trschedule.ContentTone,
trschedule.searchText,
trschedule.CountryName,
trschedule.transmissionDate,
trschedule.insDate
FROM users 
Inner Join trschedule ON users.userID = trschedule.insertID 
Inner Join rechannel ON rechannel.channelID = trschedule.channelID 
Inner Join trprogram ON trprogram.programID = trschedule.programID
WHERE (trschedule.insDate BETWEEN '2012-10-01' AND '2012-10-12')

但结果显示从(insertDate)2012-10-01至2012-10-11未显示2012-10-12的数据。

任何想法是什么原因??? /

3 个答案:

答案 0 :(得分:1)

我认为这应该有效,只需更改最后一行:

WHERE (DATE(trschedule.insDate) BETWEEN '2012-10-01' AND '2012-10-12')

答案 1 :(得分:1)

由于你没有指定日期的时间成分,mySQL将'2012-10-12'视为'2012-10-11'和'2012-10-12'之间的午夜。

尝试将之间替换为:

trschedule.insDate >= '2012-10-01' AND trschedule.insDate < '2012-10-13'

答案 2 :(得分:1)

或试试这个:

WHERE (trschedule.insDate BETWEEN '2012-10-01 00:00:00' AND '2012-10-12 23:59:59')