MySQL NAME_CONST() Function
In MySQL, the NAME_CONST()
function are for MySQL internal use only and returns a given constant value with the specified column name.
NAME_CONST()
Syntax
Here is the syntax of the MySQL NAME_CONST()
function:
NAME_CONST(column_name, const_value)
Parameters
column_name
- Required. A string that can be used as a column name.
const_value
- Required. A constant value.
Return value
MySQL NAME_CONST()
function returns the given constant value const_value
. If used to produce a result set column, the column’s name is column_name
.
NAME_CONST()
Examples
Here is the basic usage of MySQL NAME_CONST()
function.
SELECT NAME_CONST('My Name', 7);
+---------+
| My Name |
+---------+
| 7 |
+---------+
This statement is equivalent to:
SELECT 7 AS 'My Name';
+---------+
| My Name |
+---------+
| 7 |
+---------+