I’m getting Truncated incorrect INTEGER value: 'D' warning while I try to run the following query:
UPDATE MESSAGES
SET status = CASE
WHEN
(from_id='111111111' AND status='A') THEN 'S'
WHEN
(to_id ='111111111' AND status='A') THEN 'R'
WHEN
((from_id ='111111111' AND status='R') OR
(to_id ='111111111' AND status='S')) THEN 'D'
END
WHERE primary_key = '236499681204'
AND
(CASE
WHEN
(from_id='111111111' AND status='A') THEN 'S'
WHEN
(to_id ='111111111' AND status='A') THEN 'R'
WHEN
((from_id ='111111111' AND status='R') OR
(to_id ='111111111' AND status='S')) THEN 'D'
END) is not null
I have read the posts MySQL 'Truncated incorrect INTEGER value' and MYSQL Truncated incorrect INTEGER value error. But they dont apply to my case. Here, status is of type VARCHAR(1).
Is there something I’m missing?
Edit
Here’s the query for creating the table:
CREATE TABLE `MESSAGES` (
`primary_key` bigint(12) unsigned NOT NULL AUTO_INCREMENT,
`from_id` varchar(9) NOT NULL,
`to_id` varchar(9) NOT NULL,
`status` varchar(1) NOT NULL,
PRIMARY KEY (`primary_key`)
) ENGINE=MyISAM AUTO_INCREMENT=123456789876 DEFAULT CHARSET=latin1
Please help 🙁
it is not because of
statusbut because of the comparisonto avoid the error, cast the result of
CASEinto aCHARlike this:now it should work ok 🙂