I am reading MySQL in 10 Minutes.
On page 63, there is an example that isn’t explained very well.
SELECT 'abc' = 'ABC';
This gives the following result:
+----------------+ | 'abc' = 'ABC' | +----------------+ | 1 | +----------------+
What is the meaning of the table entry “1”? Does it mean that the value of the expression ‘abc’=’ABC’ is 1? Or does it mean that there is one row for which the expression is true?
I did a quick Google search, which says that SQL is supposed to have a Boolean type that gives the value of conditional expressions. Is that correct? If that is true, why is the value of the table 1 and not a Boolean?
Advertisement
Answer
1 is a representation of a Boolean (True) just the same. In the case of MySQL, actually 1 is literally how it represents True, as it doesn’t have a native Boolean type.
You are correct in your assumption, the query is evaluating abc = ABC and the result is True, therefore that 1 you are seeing is just the evaluated value.