I try to use mysql replace with following table.
CREATE TABLE price (
id BIGINT UNSIGNED AUTO_INCREMENT,
ski_chalet_id BIGINT UNSIGNED NOT NULL,
month DATE NOT NULL,
d_1 DOUBLE(18, 2),
d_2 DOUBLE(18, 2),
d_3 DOUBLE(18, 2),
d_4 DOUBLE(18, 2),
d_5 DOUBLE(18, 2),
created_at DATETIME NOT NULL,
updated_at DATETIME NOT NULL,
UNIQUE INDEX fk_ski_chalet_price_ski_chalet_idx (ski_chalet_id, month),
INDEX ski_chalet_id_idx (ski_chalet_id),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8 ENGINE = InnoDB;
I want add a row if row is not exist and update if row is exist. So i used mysql REPLACE to do that.
REPLACE INTO `price` SET `ski_chalet_id` = 43 and `month` = '2013-04-01' and `d_1` = 23
This query is successful. but add all value as 00 and 0000-00-00 or null.
But insert query is working.
INSERT INTO `price` (`ski_chalet_id`,`month`,`d_1`) VALUES ('34', '2013-04-01', '46');
I cant find whats the issue. Please help me.