CRC32() Function in MySQL
Last Updated :
05 Oct, 2020
CRC32()
function in MySQL is used to compute cyclic redundancy value. It returns NULL if the argument is NULL otherwise, it returns a 32-bit unsigned value after computing the redundancy.
Syntax :
CRC32(expr)
Parameter :
This method accepts only one parameter.
- expr -It is a string whose CRC32 value is to be retrieved.
Returns :
It returns cyclic redundancy value.
Example-1 :
Finding cyclic redundancy value for a string using CRC32 Function.
SELECT CRC32('geeksforgeeks')
AS CRC_Value;
Output :
Example-2 :
Finding cyclic redundancy value for a number using CRC32 Function.
SELECT CRC32( 2020 )
AS CRC_Value;
Output :
Example-3 :
Finding cyclic redundancy value for a NULL argument using CRC32 Function.
SELECT CRC32(NULL)
AS CRC_Value;
Output :
Example-4 :
Using CRC32 Function to find cyclic redundancy value for a column data. To demonstrate, let us create a table named Player.
CREATE TABLE Player
(
Player_id INT AUTO_INCREMENT,
Player_name VARCHAR(100) NOT NULL,
Playing_team VARCHAR(20) NOT NULL,
PRIMARY KEY(Player_id )
);
Now, insert some data to the Player table.
INSERT INTO
Player(Player_name, Playing_team)
VALUES
('Virat Kohli', 'RCB' ),
('Rohit Sharma', 'MI' ),
('Dinesh Karthik', 'KKR' ),
('Shreyash Iyer', 'DC' ),
('David Warner', 'SRH' ),
('Steve Smith', 'RR' ),
('Andre Russell', 'KKR' ),
('Jasprit Bumrah', 'MI' ),
('Risabh Panth', 'DC' ) ;
So, the Player Table is as follows.
SELECT * FROM Player;
Output :
Player_id | Player_name | Playing_team |
---|
1 | Virat Kohli | RCB |
2 | Rohit Sharma | MI |
3 | Dinesh Karthik | KKR |
4 | Shreyash Iyer | DC |
5 | David Warner | SRH |
6 | Steve Smith | RR |
7 | Andre Russell | KKR |
8 | Jasprit Bumrah | MI |
9 | Risabh Panth | DC |
Now, we will find cyclic redundancy value for Player_name and Playing_team column using CRC32 Function.
SELECT
*, CRC32(Player_name),
CRC32(Playing_team)
FROM Player;
Output :
Player_id | Player_name | Playing_team | CRC32 (Player_name) | CRC32 (Playing_team) |
---|
1 | Virat Kohli | RCB | 4234533515 | 3556712374 |
2 | Rohit Sharma | MI | 2696911654 | 185522819 |
3 | Dinesh Karthik | KKR | 703307832 | 359013669 |
4 | Shreyash Iyer | DC | 2817545593 | 974751956 |
5 | David Warner | SRH | 3645256088 | 1630650255 |
6 | Steve Smith | RR | 777202257 | 1278287345 |
7 | Andre Russell | KKR | 3090306698 | 359013669 |
8 | Jasprit Bumrah | MI | 191461017 | 185522819 |
9 | Risabh Panth | DC | 178998608 | 974751956 |
Similar Reads
COT() Function in MySQL
COT() function : This function in MySQL is used to return the cotangent of a specified number. If the specified number is 0, an error or NULL will be returned. In a right triangle, the cotangent of an angle is the length of it's adjacent side divided by the length of the opposite side. Similarly, th
1 min read
CONCAT() function in MySQL
CONCAT() function in MySQL is used to concatenating the given arguments. It may have one or more arguments. If all arguments are nonbinary strings, the result is a nonbinary string. If the arguments include any binary strings, the result is a binary string. If a numeric argument is given then it is
2 min read
ASCII() Function in MySQL
In this article, we are going to cover the ASCII function with examples and you will see the ASCII MYSQL query. And will also cover the ASCII code for the given character. Let's discuss one by one. ASCII function in MySQL is used to find the ASCII code of the leftmost character of a character expres
1 min read
CURTIME() function in MySQL
CURTIME() function in MySQL is used to check the current time. It returns the current time as a value in âhh:mm:ssâ or 'hhmmss' format, depending on whether the function is used in a string or numeric context. Syntax : CURTIME(fsp) Parameters : This method accepts only one parameter. fsp - It specif
2 min read
COUNT() Function in MySQL
The COUNT() function in MySQL is a versatile aggregate function used to determine the number of rows or non-NULL values that match a specific condition in a query. It can be applied to an entire table or a particular column and is widely used in database operations to analyze the volume of data in a
3 min read
CURDATE() Function in MySQL
The CURDATE() function in MYSQL is used to return the current date. The date is returned to the format of "YYYY-MM-DD" (string) or as YYYYMMDD (numeric). This function equals the CURRENT_DATE() function. In this article, we are going to discuss about CURDATE() function in detail. Syntax CURDATE(); P
2 min read
EXTRACT() Function in MySQL
The EXTRACT() function in MySQL is a versatile tool used for retrieving specific components of date Whether we need the year, month, day or even the hour or minute. This function simplifies date manipulation and makes queries involving date and time data more efficient and easier to understand. In t
3 min read
ELT() Function in MySQL
In this article, we are going to cover ELT function with examples. In ELT function, number field will state that how many strings will be there. ELT function in MySQL is used to returns the string which is at index number specified in the argument list. In this function there is number field and str
1 min read
DAY() Function in MySQL
DAY() function : This function in MySQL is used to return the day of the month for a specified date (a number from 1 to 31). This function equals the DAYOFMONTH() function. Syntax : DAY(date) Parameter : This method accepts a parameter which is illustrated below : date : Specified date to extract th
1 min read
EXP() Function in MySQL
EXP() function in MySQL is used to returns E raised to the power of a specified number. Here E(2.718281...) is the base of the natural logarithm. Syntax : EXP(X) Parameter : This method accepts one parameter as mentioned above in the syntax and described below : X â A specified number which will be
2 min read