bokeh
07-11-2006, 11:59 AM
What data types are most commonly used to represent a boolean in MySQL and why?
|
Click to See Complete Forum and Search --> : boolean bokeh 07-11-2006, 11:59 AM What data types are most commonly used to represent a boolean in MySQL and why? chazzy 07-11-2006, 12:02 PM sometimes i use enum(0,1) because I can do this: SELECT CASE `my_column` WHEN 1 then 'TRUE' WHEN 0 then 'FALSE' end FROM `my_table` if for purely reporting capabilities. what is the application bokeh 07-11-2006, 01:29 PM What is that doing? Does it return a true boolean to the scripting language? chazzy 07-11-2006, 01:46 PM no, returns the text "true" or "false", it's just easier to read to most languages, you can only return strings from SQL - in some cases like Pro C/Pro C++ it can map the Oracle Datatypes to valid types in C/C++. Also, you can use databinding techniques (in php, java, etc) to map the query results to variables for some form of data type validation. bokeh 07-11-2006, 02:16 PM Ok! I was already using ENUM('0','1') so it look like I made a reasonable choice. String "0" evaluates to false in PHP whereas string "false" evaluate to true so for my use I think sticking with zero and one looks preferable. mattyblah 07-12-2006, 11:43 AM Bit fields are usually used to represent boolean, at least that's what I use. You can only store 0 or 1. webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |