Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
MySQL doesn't have a Boolean type per se. It does have a Boolean keyword which maps to a tiny int which is then used as a Boolean type. So, let's see how this works. We'll use the scratch database here. And we're going to go ahead and create a little table here. We'll start with a DROP TABLE IF EXISTS. And CREATE TABLE test and it's just going to have two columns a and b and they're both Boolean.
Actually just BOOL by itself is an alias for Boolean, either one works. I like to spell things out. And we're going to insert one row and just put in TRUE and FALSE, true and false. They're just aliases for one and zero, and so true is one and false is zero. And we'll SELECT FROM test, we'll DESCRIBE it, and we'll SHOW CREATE TABLE. Go ahead and Go. So here we have our select here which shows one and zero, and our describe actually shows tiny end for both of the values and you'll notice that it says tiny end one which means that only one digit is going to be used there.
And our CREATE TABLE shows that it's created with tiny and DEFAULT NULL. And so if we come in here and we don't need to describe the any longer and we say SELECT a AND b and SELECT t a OR b. You notice that these can be used, we need FROM test. I do make typos sometimes. And that's fine. And so we see a AND b is not true so it's a 0 because TRUE and FALSE is false.
TRUE or FALSE however is true and so, that returns a 1. So MySQL simply maps its Boolean type to a tiny int, which is then used as a Boolean value. So we can go ahead and DROP our TABLE to put the database back into its original state, and to be ready for the rest of our lessons.
Get unlimited access to all courses for just $25/month.Become a member
61 Video lessons · 92812 Viewers
82 Video lessons · 104221 Viewers
71 Video lessons · 75910 Viewers
56 Video lessons · 107268 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.