I want to insert the value into a bit type column in MySQL. But I am getting a data truncation error.
CREATE TABLE `BITTESTTABLE` (
`db_field` varchar(50) NOT NULL,
`is_editable` bit(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
If I am inserting a row with
INSERT INTO BITTESTTABLE values('XYZ','0')
I am getting
Data too long for column 'is_editable' at row 1
So how do I insert the data for bit type column?
You should use:
INSERT INTO `BITTESTTABLE` VALUES('XYZ', b'0');
Since bit is a number not a string you need enter it like
INSERT INTO BITTESTTABLE values('XYZ',0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With