ID EN
Miscellaneous Functions

NAME_CONST(name,value)

MySQL 8.4

Returns the given value. When used to produce a result set column, NAME_CONST() causes the column to have the given name. The arguments should be constants.

Syntax

MYSQL
SELECT NAME_CONST('myname', 14);
+--------+
| myname |
+--------+
|     14 |
+--------+

Examples

Example

This function is for internal use only. The server uses it when writing statements from stored programs that contain references to local program variables, as described in Section 27.7, “Stored Program Binary Logging”. You might see this function in the output from mysqlbinlog.

MYSQL
SELECT NAME_CONST('myname', 14);
+--------+
| myname |
+--------+
|     14 |
+--------+
Example 2

For your applications, you can obtain exactly the same result as in the example just shown by using simple aliasing, like this:

MYSQL
SELECT 14 AS myname;
+--------+
| myname |
+--------+
|     14 |
+--------+
1 row in set (0.00 sec)