Last active
September 29, 2015 15:37
-
-
Save cmbuckley/1623177 to your computer and use it in GitHub Desktop.
Workaround MySQL solution for http://stackoverflow.com/q/8888349
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE `input` (`dt` DATETIME, `r` INT); | |
CREATE TABLE `output` (`dt` DATETIME, `r` INT); | |
LOAD DATA INFILE 'input.log' INTO TABLE `input` FIELDS TERMINATED BY ' ' LINES TERMINATED BY '\n'; | |
LOAD DATA INFILE 'output.log' INTO TABLE `output` FIELDS TERMINATED BY ' ' LINES TERMINATED BY '\n'; | |
(SELECT * | |
FROM `input` | |
INNER JOIN `output` | |
ON `output`.`dt` > `input`.`dt` + INTERVAL 5 SECOND | |
AND `input`.`r` = `output`.r`) | |
UNION | |
(SELECT * | |
FROM `input` | |
LEFT JOIN `output` | |
ON `input`.`r` = `output`.`r` | |
WHERE `output`.r` IS NULL); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment