SERIAL()

Function description

The SERIAL() function is used to serialize a connection string, combining a single or multiple columns/values into a binary format, with the return type VARCHAR. It is similar to CONCAT(), but in CONCAT(), the type information of the value cannot be captured. Generally used with the SERIAL_EXTRACT() function.

If any of the parameters in SERIAL() is NULL, NULL is returned. To process NULL values, use SERIAL_FULL().

Function Syntax

Text
> SERIAL(para)

Parameter definition

Parameters

Description

para

Column/value to serialize

Example

Text
create table t1(a varchar(3), b int);
insert into t1 values("ABC",1);
insert into t1 values("DEF",NULL);

mysql> select serial(a,b) from t1;--The query returns the result of serialization of column a and column b. When there is a NULL value, the output is NULL
+--------------+
| serial(a, b) |
+--------------+
| FABC :       |
| NULL         |
+--------------+
2 rows in set (0.00 sec)

mysql> select serial(a,'hello') from t1;--Query returns the result of a column and value hello combination serialization
+------------------+
| serial(a, hello) |
+------------------+
| FABC Fhello      |
| FDEF Fhello      |
+------------------+
2 rows in set (0.00 sec)
Last updated on