Destramic Posted February 21, 2006 Share Posted February 21, 2006 k i have a field in my table but i want to know what type to set my news status as:have a field called "status" for my newseither it should be a field that contains the value true or false ie. 0 or 1or on the other hand i could have the value "Active" or "Inactive"what field type would be the best for this and what would be the best way?thanks..how comeone can help me on my query Quote Link to comment https://forums.phpfreaks.com/topic/3520-field-type-help/ Share on other sites More sharing options...
fenway Posted February 22, 2006 Share Posted February 22, 2006 I would say to use the ENUM data type -- you can use the words "active" and "inactive", and the DB will encode these as 0 or 1. This way, you can have the best of both worlds; plus, it's more flexible if you ever want to add a 3rd type. Quote Link to comment https://forums.phpfreaks.com/topic/3520-field-type-help/#findComment-12111 Share on other sites More sharing options...
Destramic Posted February 22, 2006 Author Share Posted February 22, 2006 k thank you..but this is the mysql error im getting[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]ALTER TABLE `games` CHANGE `status` `status` ENUM( 1 ) NOT NULL DEFAULT '0' #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1) NOT NULL DEFAULT '0'' at line 1 [/quote] Quote Link to comment https://forums.phpfreaks.com/topic/3520-field-type-help/#findComment-12134 Share on other sites More sharing options...
fenway Posted February 22, 2006 Share Posted February 22, 2006 You don't explicitly define the integer components:[code]ALTER TABLE `games` CHANGE `status` `status` ENUM( 'inactive', 'active' ) NOT NULL DEFAULT 'active'[/code]You can, of course, switch the order of the fields. Quote Link to comment https://forums.phpfreaks.com/topic/3520-field-type-help/#findComment-12187 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.