Which datatype is used for storing true/false
information in MySQL?
Especially when writing and reading with a PHP-Script.
Over time I have used and seen several approaches:
tinyint, varchar fields containing the values 0/1, varchar fields containing the strings '0'/'1' or 'true'/'false' and finally enum Fields containing the two options 'true'/'false'.
Not one seems optimal, I prefer the tinyint 0/1 variant
, since automatic type conversion in PHP gives me boolean values rather simply.
So, is there a type designed for boolean values which I have overlooked?
Do you see any advantages/disadvantages by using one type or another?
For MySQL 5.0.3 and higher, you can use BIT or TINYINT.
Here you have a more elaborated answer