Which MySQL field should I use for the Yes / No Checkbox value?

I am using the MySQL table below. I would like to add a field called 'subcheck' which will be the yes / no value determined by the input of the HTML form TYPE = CHECKBOX . What "type" should I give this new field?

Thanks in advance,

John

 `submission` ( `submissionid` int(11) unsigned NOT NULL auto_increment, `loginid` int(11) NOT NULL, `title` varchar(1000) NOT NULL, `slug` varchar(1000) NOT NULL, `url` varchar(1000) NOT NULL, `displayurl` varchar(1000) NOT NULL, `datesubmitted` timestamp NOT NULL default CURRENT_TIMESTAMP, PRIMARY KEY (`submissionid`) ) 
+6
html mysql
source share
5 answers

You can use TINYINT(1) (BOOL / BOOLEAN is just an alias for TINYINT(1) ).

Another option is to store Y/N in CHAR(1) .

I would recommend TINYINT(1) as it will provide you with the best portability features.

+14
source share

a boolean - 1 for yes, 0 for no.

(the value of the flag should be 1 or 0, of course).

Much more portable than yes / no imo. effective too

+2
source share

I personally prefer the enumeration or the given data type in MySQL for this. It keeps the data readable.

+2
source share

I would use numeric(1) not null default 0 , where 0 indicates false and 1 indicates true .

+1
source share

I would recommend TINYINT(1) for this purpose. It saves either 1 or 0 to indicate yes or no. It takes up very little space and is better supported in different SQL machines than regular bool types.

0
source share

All Articles