With MySQL, we can do complex calculations very easily with the help of inbuilt mathematical functions. CRC32(str) helps in calculating the cyclic redundancy check value and returns a 32-bit unsigned value.
Now let’s start with it.
CRC32(str) is a mathematical function. CRC means cyclic redundancy check.
A cyclic redundancy check (CRC) is an error-detecting code commonly used in digital networks and storage devices to detect accidental changes to raw data.
Computes a cyclic redundancy check value and returns a 32-bit unsigned value. The argument is expected to be a string and (if possible) is treated as one if it is not.
If the argument is not a string, MySQL treats it as one anyway (either that, or you’ll get an error).
It returns the CRC of input string str. Where str is the argument, whose value will be passed by the user.
It will return NULL, if str is passed as NULL.
Name, Required /Optional, Description
str , Required, A string whose CRC32 value is to be fetched.
Return, Description
NULL, if the argument is NULL.
It returns 32-bit unsigned value cyclic redundancy value of input string.
See the below example. See the output, when ‘www.tutorialmines.net’ is passed.
mysql> SELECT CRC32('www.tutorialmines.net') AS 'crc value'; +------------+ | crc value | +------------+ | 2600963911 | +------------+ 1 row in set (0.00 sec)
Now, Let’s change the input value to 56456. See what it returns.
mysql> SELECT CRC32(56456) AS 'crc value'; +-----------+ | crc value | +-----------+ | 877297141 | +-----------+ 1 row in set (0.00 sec)
We are using the PI() function to get the value of CRC32() with it. I get the below value.
mysql> SELECT CRC32(PI()) AS 'crc value'; +------------+ | crc value | +------------+ | 2969982827 | +------------+ 1 row in set (0.00 sec)
Here you can see the different results on the basis of the case of your arguments.
mysql> SELECT CRC32('TUTORIALMINES'), CRC32('Tutorialmines'), CRC32('TutorialMINES'); +------------------------+------------------------+------------------------+ | CRC32('TUTORIALMINES') | CRC32('Tutorialmines') | CRC32('TutorialMINES') | +------------------------+------------------------+------------------------+ | 1993232533 | 3824949637 | 346610485 | +------------------------+------------------------+------------------------+ 1 row in set (0.00 sec)
If the argument is NULL, it will return NULL. See the below example :
mysql> SELECT CRC32(NULL) AS 'crc value'; +-----------+ | crc value | +-----------+ | NULL | +-----------+ 1 row in set (0.00 sec)
App usage is growing steadily without showing any signs of slowing down. Hence, it is no surprise that mobile applications…
As the world has grown more digital, businesses have adapted themselves. An effectual adaptation includes online advertising. Offline advertising styles…
Step into a world where apps dance to the user's tune. Picture Instagram, a photo-sharing sensation that swept the globe.…
COVID-19 has led to a digitalization of lifestyle. As patients are taking their mental and physical health more seriously, healthcare…
Introduction WordPress, an immensely popular content management system (CMS), powers over 40% of the internet. What makes WordPress even more…
For moving companies trying to capture their market share amidst stiff competition, a tip or two about what they can…