Expression Evaluation and Type Conversion

MySQL allows you to write expressions that include constants, function calls, and references to table columns. These values may be combined using different kinds of operators, such as arithmetic or comparison operators, and terms of an expression may be grouped with parentheses.

Expressions occur most commonly in the column selection list and WHERE clause of SELECT statements:

SELECT
    CONCAT(last_name, ", ", first_name),
    (TO_DAYS(death) - TO_DAYS(birth) / 365)
FROM president
WHERE
    birth > "1900-1-1" AND DEATH IS NOT NULL

Each column selected represents an expression, as does the content of the WHERE clause. Expressions also occur in the WHERE clause of DELETE and UPDATE statements, the VALUES() clause ...

Get MySQL now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.