mysql boolean data type

In MysQL, there is no datatype called boolean or bool, but the datatype tinyint serves the purpose of boolean. With tyinyint, a 0 means false and a non-zero means true. Assume there is this table

CREATE TABLE booleantb(
	id INT(11) NOT NULL AUTO_INCREMENT,
	success TINYINT(1) DEFAULT NULL,
	PRIMARY KEY (id)
);
INSERT INTO booleantb(success) VALUE(1);

The field success can be updated with true or false. true will set the value to 1 and false will set the value to 0.

UPDATE booleantb SET success=FALSE WHERE id=1;
UPDATE booleantb SET success=TRUE WHERE id=1;  

Search within Codexpedia

Custom Search

Search the entire web

Custom Search