Wednesday, 22 August 2012

Mysql


Get data at certain time period

select * from smartcontainer.SENSOR_DATA where SAMPLING_TIME> '2012-07-28 15:11:45' and SAMPLING_TIME < '2012-07-28 15:12:00';


Datebase to text

select * from smartcontainer.SENSOR_DATA where SAMPLING_TIME> '2012-07-31 00:00:00' and SAMPLING_TIME < '2012-07-31 24:00:00' and VALUE_STRING = 'Telosb41_Temperature' into outfile '/tmp/Telosb41.txt' ;

Get Latest Value

select * from sensor_data where sampling_time in (select max(sampling_time) from sensor_data group by sensor_id