#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    59
    Rep Power
    2

    Which datatype is used for checkbox


    Hi,

    I am building my 1st MySQL database and have 1 question:

    1) If I want to have a checkbox linked to a field in a table, what Data Type do I set for that field?

    Thanks and Regards
    Sarath
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,026
    Rep Power
    4210
    i would use CHAR(1) because it's portable to other database systems (i.e. it's non-proprietary, unlike, say, ENUM)
    r937.com | rudy.ca
    please visit Simply SQL and buy my book
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Sep 2006
    Posts
    1,799
    Rep Power
    529
    Originally Posted by r937
    unlike, say, ENUM
    Yikes, the spawn of the devil!

    If the checkbox is yes/no, what about tinyint?
  6. #4
  7. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,026
    Rep Power
    4210
    TINYINT is okay, except it isn't quite as portable as CHAR
    r937.com | rudy.ca
    please visit Simply SQL and buy my book

IMN logo majestic logo threadwatch logo seochat tools logo