Chapter 15. The User Variable and the SET Statement

15.1 Introduction

In MySQL, we can define variables—the user variables or user-defined variables. We can assign values to user variables and use them in the same place where scalar expressions normally are used. As a result, the statement becomes partly variable. By changing the value of the user variable, the statement changes.

Before you introduce a user variable, you must define it. You do this with the special SET statement or with a SELECT statement.

After defining a variable, you must assign a value; otherwise, the variable has the null value. Again, with SET and SELECT statements, a value can be assigned explicitly to a user variable.

Section 5.6 briefly described the user variable; ...

Get SQL for MySQL Developers: A Comprehensive Tutorial and Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.