weemikey Posted July 18, 2007 Share Posted July 18, 2007 Hi all. I've done a bunch of reading online, but I'm still confused about what data types to use and more importantly how to do comparisons. I've just started php/mysql stuff and I'm starting to get it, but this one is killing me tonight. Scenario: I have a field in my db that I want to be YES/NO. In other db's I've used that's a clear LOGICAL data type. If that exists in mysql I don't know what it's called. I want to have two fields in one table: "remember" (as in remember me...) which I'd like to be YES or NO. Same for "activated" which is used to check if someone has gotten a "click here to activate" email and followed through with the sign up process. In my db I have these field set up as varchar with a default value of 'NO'. When viewing the table in phpmyAdmin the value is stored as 'NO' with the single quotes. Any other varchar data, such as an email address is stored just as it was entered without single quotes. So when I'm doing some php stuff to compare values I don't know if I'm supposed to use single quotes or double quotes or NO quotes. I'm trying to compare things like "if this db field = NO", but I don't know if I'm supposed to use "NO", 'NO' or NO. Get it? How can I set this up so the value is either YES/NO and I can refer to it like that? Does that make sense? I don't know if it's my db setup or my coding syntax. So confused! Quote Link to comment https://forums.phpfreaks.com/topic/60498-solved-question-on-data-types/ Share on other sites More sharing options...
fenway Posted July 18, 2007 Share Posted July 18, 2007 Well, there are ENUM and BINARY data types... Quote Link to comment https://forums.phpfreaks.com/topic/60498-solved-question-on-data-types/#findComment-301208 Share on other sites More sharing options...
Wildbug Posted July 18, 2007 Share Posted July 18, 2007 There's a BOOLEAN type (syn. for TINYINT(1)). http://dev.mysql.com/doc/refman/5.1/en/numeric-type-overview.html Or, as fenway said, ENUM('Yes','No'). Both solutions require one byte for storage. Quote Link to comment https://forums.phpfreaks.com/topic/60498-solved-question-on-data-types/#findComment-301279 Share on other sites More sharing options...
weemikey Posted July 18, 2007 Author Share Posted July 18, 2007 Thanks for your help. The tinyint is just what I was looking for. Quote Link to comment https://forums.phpfreaks.com/topic/60498-solved-question-on-data-types/#findComment-301345 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.