select *
from my_table
where parameter1 = 'Goofy'
and DATE(FROM_UNIXTIME(time)) >= '2020-05-13 00:00:00.000 0000' --startdate
and DATE(FROM_UNIXTIME(time)) <= '2020-05-15 00:00:00.000 0000' --enddate
and TIME(FROM_UNIXTIME(time)) >= '01-01-1970 12:22:00.000 0000' --starttime
and TIME(FROM_UNIXTIME(time)) <= '01-01-1970 19:33:00.000 0000' --endtime
在Mongo(php API)中,我的查询看起来像
$query = [
'$and' => [
['parameter1' => 'Goofy']
,['time' => [$gte => <conversion to unixtime for date '2020-05-13 00:00:00.000 0000' >]]
,['time' => [$lte => <conversion to unixtime for date '2020-05-15 00:00:00.000 0000' >]]
,['time' => [$gte => <conversion to unixtime for time '01-01-1970 12:22:00.000 0000' >]]
,['time' => [$lte => <conversion to unixtime for time '01-01-1970 19:33:00.000 0000' >]]
]
];
$cursor = (new MongoDB\Client())->selectCollection('myDb', 'myTable')->find($query,[]);
我有一个时间戳记为unix时间(以毫秒为单位)和UTC查询参数的查询,我的SQL查询就像select * from my_table,其中parameter1 ='Goofy'和DATE(FROM_UNIXTIME(...