vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, there's something odd I don't understand, or maybe a bug... I want to transfer data from one table to another, like this (reduced to elementary items): source: key - timestamp - count target: key - tsLastUpdate - tsOldestEntry - totalCount At first I read all data from source and generate the insert statement with multiple value items. My insert-statement: INSERT DELAYED INTO `target` ( `key`,`tsLastUpdate`,`tsOldestEntry`,`totalCount` ) VALUES (....) ON DUPLICATE KEY UPDATE `tsLastUpdate`=IF(`tsLastUpdate`<VALUES(`timestamp `), VALUES(`timestamp`), `tsLastUpdate`), `tsOldestEntry`=IF(`tsOldestEntry`>VALUES(`timesta mp`), VALUES(`timestamp`), `tsOldestEntry`), `cntTotal`=`cntTotal`+VALUES(`count`) VALUES(...) contains the datasets to insert/update (there're many of them). Table definition is like: CREATE TABLE `target` ( `key` varchar(255) character set utf8 NOT NULL default '', `tsLastUpdate` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, `tsOldestEntry` timestamp NOT NULL default '0000-00-00 00:00:00' `totalCnt` int(10) unsigned NOT NULL default '0', PRIMARY KEY (`key`), KEY `tsLastUpdate` (`tsLastUpdate`), KEY `tsOldestEntry` (`tsOldestEntry`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 tsOldestEntry should reflect the lowest timestamp given for each key-dataset. It should never increase. tdLastUpdate shows -of course- the timestamp of the last update. But tsOldestEntry IS GROWING, and I don't know why! For some entries it is even grater than tsLastUpdate, what i would't expect at all, under no circumstances. How can this be? There are a lot of datasets within the source data with the same key, but different timestamps. Is that a problem? Did i make something wrong, does '>' not work with timestamps, or did I miss something else? I'm quite confused... regards, andy PS: plz excuse my bad english |