between 이나 TIMEDIFF 이런걸로 될 줄 알았는데 영안되서
결국에는 +-15로 계산을 해야겠네.. 끄응
select T.temperature, T.humidity, T.created as tcreated, P.ph, P.voltage, P.created as pcreated from (select * from dht11 where DATE(created) >= '2018-12-20' ) as T, (select * from ph where DATE(created) >= '2018-12-20' ) as P WHERE TIME_TO_SEC(P.created) - 15 < TIME_TO_SEC(T.created) AND TIME_TO_SEC(T.created) < TIME_TO_SEC(P.created) + 15; |
[링크 : https://www.w3resource.com/mysql/date-and-time-functions/mysql-time_to_sec-function.php]
[링크 : https://stackoverflow.com/questions/7636599/calculating-time-difference-between-2-dates-in-minutes]
[링크 : https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_timestampdiff]
'프로그램 사용 > mysql & mariaDB' 카테고리의 다른 글
mysql / unix-socket (0) | 2019.09.04 |
---|---|
mysql exists (0) | 2019.07.05 |
mysql join과 필드명 변경하기 (0) | 2018.12.21 |
join은 위험한 동물이다(?) (0) | 2018.12.21 |
mysql client 다른 호스트 접속하기 (0) | 2018.12.20 |