2013-10-01 53 views
-1

查詢1爲什麼查詢得到0行

SELECT SessionInfo.IVRSessionInfoID   
    FROM SessionInfo 
    WHERE SessionCallTime BETWEEN UNIX_TIMESTAMP('2013-08-01 00:00:00') 
     AND UNIX_TIMESTAMP('2013-08-01 23:59:59') 
    ORDER BY SessionInfo.SessionCallTime DESC; 

QUERY2

  SELECT SessionInfo.IVRSessionInfoID   
      FROM SessionInfo 
     WHERE (SessionInfo.SessionCallTime BETWEEN '2013-08-01 00:00:00' 
             AND '2013-08-01 23:59:59') 
      ORDER BY SessionInfo.SessionCallTime DESC; 

是什麼之探源爲什麼第一個查詢給出0行 第二查詢給人記錄

此表中的20000行betwqeen這兩個日期

表格架構

CREATE TABLE `SessionInfo` (
    `IVRSessionInfoID` bigint(8) unsigned NOT NULL AUTO_INCREMENT, 
    `SessionCallTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 
    `MGServerIP` varchar(15) NOT NULL, 
    `MGServerPort` smallint(2) unsigned NOT NULL DEFAULT '5060', 
    `SessionUniqueID` varchar(64) NOT NULL, 
    `ANI` varchar(20) NOT NULL, 
    `CountryID` int(4) unsigned DEFAULT NULL, 
    `CountryStateAreaID` int(4) unsigned DEFAULT NULL, 
`AccessNumberProviderLogID` int(4) unsigned DEFAULT NULL, 
`AccessNumberLogID` int(4) unsigned DEFAULT NULL, 
    `AccessRestrictionLogID` int(4) unsigned DEFAULT NULL, 
`SubscriberCardID` bigint(8) unsigned DEFAULT NULL, 
    `SessionDuration` int(4) unsigned NOT NULL, 
`SessionRNDDuration` int(4) unsigned NOT NULL, 
`TotalCharge` decimal(15,6) unsigned NOT NULL, 
`RuleSetLogID` int(4) unsigned DEFAULT NULL, 
`RuleSetChargeInfoLogID` int(4) unsigned DEFAULT NULL, 
`RuleSetRNDDuration` int(4) unsigned NOT NULL, 
`RuleSetTotalCharge` decimal(15,6) unsigned NOT NULL, 
PRIMARY KEY (`IVRSessionInfoID`), 
    UNIQUE KEY `UNIQUE` (`SessionUniqueID`), 
    KEY `SessionCallTime` (`SessionCallTime`), 
    KEY `ANI` (`ANI`), 
    KEY `CountryID` (`CountryID`), 
    KEY `CountryStateAreaID` (`CountryStateAreaID`), 
    KEY `AccessNumberProviderLogID` (`AccessNumberProviderLogID`), 
    KEY `AccessNumberLogID` (`AccessNumberLogID`), 
    KEY `AccessRestrictionLogID` (`AccessRestrictionLogID`), 
    KEY `SubscriberCardID` (`SubscriberCardID`), 

    ) ENGINE=InnoDB AUTO_INCREMENT=22199955 DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT;   
+1

您將需要提供至少最小的表架構。無論如何,我認爲這是一個offtopic在這裏。 – kworr

回答

3

這個問題可能更適合於DBA交換...

...但我的猜測是因爲UNIX_TIMESTAMP('anything')回報和int/decimal/number'2013-08-01 23:59:59'一些數據庫DateTime數據類型的格式。

EG:SessionInfo.SessionCallTime不使用與UNIX_TIMESTAMP()兼容的數據類型。

相關問題