Forum Moderators: open

Message Too Old, No Replies

boolean query

         

bleak26

12:47 pm on May 10, 2006 (gmt 0)

10+ Year Member



just out of curiousity does anyone know why you can store values greater than 1 in boolean fields in mysql.

ChadSEO

2:51 pm on May 10, 2006 (gmt 0)

10+ Year Member



bleak26,

Looking at the MySQL documentation, it looks like BOOL(EAN) is a synonym for TINYINT, which will store values from -128 to 127. Testing on MySQL 4.1.15, I was able to confirm this. I don't imagine this would change between versions, but it's probably worth testing before you rely on it.

Chad

coopster

2:58 pm on May 10, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



That is correct, MySQL maps data types [dev.mysql.com] for BOOL or BOOLEAN as

BOOLEAN = TINYINT(1)

That number 1 there (as well as column type TINYINT itself) are extensions to the standard. The number 1 is the display width and it does not constrain the range of values that can be stored in the column, nor the number of digits that are displayed for values having a width exceeding that specified for the column.

[dev.mysql.com...]