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
[code language=”sql”]
CREATE TABLE booleantb(
id INT(11) NOT NULL AUTO_INCREMENT,
success TINYINT(1) DEFAULT NULL,
PRIMARY KEY (id)
);
INSERT INTO booleantb(success) VALUE(1);
[/code]
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.
[code language=”sql”]
UPDATE booleantb SET success=FALSE WHERE id=1;
UPDATE booleantb SET success=TRUE WHERE id=1;
[/code]
Search within Codexpedia
Custom Search
Search the entire web
Custom Search
Related Posts