MariaDB Tutorial MariaDB Advanced MariaDB Database Account Management MariaDB References

MariaDB CRC32() Function



The MariaDB CRC32() function is used to compute a cyclic redundancy check value and returns a 32-bit unsigned value. It returns NULL if the argument is NULL. The argument is expected to be a string and (if possible) is treated as one if it is not.

Syntax

CRC32(expr)

Parameters

expr Required. Specify the string whose CRC32 value is to be retrieved.

Return Value

Returns the cyclic redundancy value.

Example 1:

The example below shows the usage of CRC32() function.

SELECT CRC32(10);
Result: 2707236321

SELECT CRC32('MariaDB');
Result: 4227209140

SELECT CRC32('Learn SQL');
Result: 428816044

SELECT CRC32('');
Result: 0

SELECT CRC32(' ');
Result: 3916222277

SELECT CRC32(NULL);
Result: NULL

Example 2:

Consider a database table called Employee with the following records:

EmpIDNameCityAge
1JohnLondon25
2MarryNew York24
3JoParis27
4KimAmsterdam30
5RameshNew Delhi28

To get the cyclic redundancy value of all records of Name column of this table, the following query can be used:

SELECT *, CRC32(Name) AS CRC32_Value FROM Employee;

This will produce a result similar to:

EmpIDNameCityAgeCRC32_Value
1JohnLondon252437433000
2MarryNew York242256442705
3JoParis272520959417
4KimAmsterdam3078804536
5RameshNew Delhi282499654632
6SureshMumbai283267040966

❮ MariaDB Functions