From the course: MySQL Essential Training (2019)

Unlock this course with a free trial

Join today to access over 22,500 courses taught by industry experts.

The CASE statement

The CASE statement

- [Instructor] My SQL supports a form of the standard SQL conditional expression syntax. The syntax is a little cumbersome, but here's how it works. For this example we're going to use the scratch database, we're going to create a little table, the table has two columns, both of them integers named A and B and we're going to insert a couple of values into that table in one row and here we'll select so we can see what happens. I'm going to shift and execute here and we'll go ahead and close this bottom pane. You'll notice we get a little warning because the table didn't exist. I always start these things with a drop table if exists just in case there's a table leftover from before or something like that. So here we have our table and you'll notice we have one row with two values, A is a one and B is a zero. Keep in mind that in SQL zero is treated as false in binary context, or rather in boolean context, and any non-zero value is treated as true. And so this is boolean true in A and B…

Contents