Insert multiple (INSERT INTO ...VALUES SELECT...)
Bonsoir,
Je me remets au SQL, et finalement, on oublie vite !
J'essaie de résoudre ceci et je tourne en rond, il doit y avoir un truc qui crève les yeux :(. Le select fonctionne.
Code:
1 2 3 4 5 6 7 8 9
|
insert into `linknx`.`log_TEMP` (`ts`, `object`, `value`) VALUES
select
`ts`,
`object`,
`value`
FROM `linknx`.`log`
WHERE `object` LIKE 'consommation'
HAVING ts >= '2014-05-09 21:00:00' and ts <= '2014-05-09 21:59:59'; |
Mes 2 tables sont identiques :
Code:
1 2 3 4 5 6
| CREATE TABLE IF NOT EXISTS `log_TEMP` (
`ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`object` varchar(256) NOT NULL,
`value` varchar(256) NOT NULL,
KEY `object` (`object`,`ts`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8; |
J'obtiens l'erreur suivante
Citation:
:#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select `ts`, `object`, `value` FROM `linknx`.`log` WHERE `object` LIK' at line 2
Merci pour votre aide.
Arnaud