From the course: MySQL Essential Training (2019)

Unlock this course with a free trial

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

Logical operators

Logical operators

- [Instructor] MySQL provides boolean logical operators for combining conditional expressions. Keep in mind that in SQL zero is treated as false and any non-zero value is treated as true. So, if I select one and one, I'll get a true result, which is one, because true and true is true. If I say or instead of and and execute I still get one, because true or true is true. If I make this a zero I still get true, because true or false is true because only one of the operands needs to be true for the result to be true. There's also XOR and when I execute I get one, because one XOR zero is true. XOR requires that one side of the operation is true and the other side is false. So, if I say one XOR one, now this is false, because both sides are true. You can also use is and is not to compare logical values. So, I can say one is true and I execute that and that is true, or I can say one is not true, and the result is false, because one is true. I can also use is and is not to compare against the…

Contents