As you can see, date and bed form a composite primary key.
I am trying to run this query:
INSERT INTO days (date, operating_time, bed) VALUES ('2016-11-07', 6.55, 1) ON duplicate key update operating_time=VALUES(operating_time);
The problem is that it seems to update based only on the date column. So for example, running the above query for a bed value of 1, and then re-running it but with a bed value of 2 will actually update the original record (the one where bed = 1)
How can I make the ON DUPLICATE KEY
statement check both the date and bed columns?
Edit
Here is the create statement for the table:
CREATE TABLE `days` (
`date` date NOT NULL,
`operating_time` float DEFAULT '0',
`bed` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`date`,`bed`),
UNIQUE KEY `date_UNIQUE` (`date`),
KEY `bed_idx` (`bed`),
KEY `date` (`date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;