×

MySQL EXPORT_SET() function

In this context, we will learn how we can use the MySQL EXPORT_SET() function with proper syntax and good examples.

Introduction of MySQL EXPORT_SET() function

This function returns a string and shows the bits in a number. 5 arguments are required to return a true result for this function. It converts Integer to Binary digits and returns "on" if the binary digit is 1 and "off" if the binary digit is 0.

Syntax of the MySQL EXPORT_SET() function

The syntax of the MySQL EXPORT_SET() function is given as follows:

EXPORT_SET(bits, on, off, separator, number of bits)

Parameters or arguments used in MySQL EXPORT_SET() function:

There are five parameters accepted by the EXPORT_SET() function in MySQL, which are mentioned above and described as follows:

1. bits –

This is the integer number for which the result will be formatted in this function.

2. on –

It will return when the binary digit is 1.

3. off –

It will return off when the binary digit is 0.

4. separator –

Between returned values this separator will be placed in it .

5. number of bits –

The number of bits in which the result will come

Returns:

This function will return a string that will show the bits in the number.

Application used for EXPORT_SET() function:

The EXPORT_SET() function can be used in the given below MySQL versions.:

  • MySQL 5.7
  • MySQL 5.6
  • MySQL 5.5
  • MySQL 5.1
  • MySQL 5.0
  • MySQL 4.1
  • MySQL 4.0
  • MySQL 3.23

Examples of MySQL EXPORT_SET() function:

Now we will look into some MySQL EXPORT_SET() function examples and will explore how we can use the EXPORT_SET function in MySQL.

Example-1 :

Here, we will see the Working of EXPORT_SET() function.

SELECT EXPORT_SET(10, 'On', 'Off', ':', 5) AS ExportSET;

Output:

ExportSET
Off: On : Off : On : Off
1 row in set (0.00 sec)

Example 2 :

Here, we will see the Working of EXPORT_SET() function by changing 2nd and 3rd arguments.

Here we will Use "Y" and "N" as the second and third arguments, respectively–

SELECT EXPORT_SET(11, 'Y', 'N', ', ', 4)
AS Export;

Output :

Export
Y, Y, N, Y
1 row in set (0.00 sec)

Here we will Use "1" and "0" as the second and third arguments, respectively –

SELECT EXPORT_SET(11, 1, 0, ', ', 4)
AS Export;

Output :

Export
1, 1, 0, 1
1 row in set (0.00 sec)

Example-3 :

Now, we will see the Working of the EXPORT_SET() function by changing the 4th argument.

In this example, we will use "-" as the fourth argument –

SELECT EXPORT_SET(10, 1, 0, '-', 4) AS ExportSET;

Output:

ExportSET
0-1-0-1
1 row in set (0.00 sec)

Here we will use "::" as the fourth argument –

SELECT EXPORT_SET(10, 1, 0, '::', 4)
AS Export;

Output:

Export
0::1::0::1
1 row in set (0.00 sec)

Example 4 :

Now, we will see the Working of the EXPORT_SET() function by changing the 5th argument.

Here we will Use 10 as the fifth argument –

SELECT EXPORT_SET(9, 'Y', 'N',' ', 10)
AS Export;

Output:

Export
Y N N Y N N N N N N
1 row in set (0.00 sec)

Here we will Use 20 as the fifth argument –

SELECT EXPORT_SET(9, 1, 0, ' ', 20)
AS Export;

Output:

Export
1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 row in set (0.00 sec)

Application of MySQL EXPORT_SET() function:

This function helps to return a string which will show the bits in the number.

Summary:

In the above context, we have learned how to use the EXPORT_SET() function in MySQL, which helps return a string that will show the bits in the number.


Related Topics

MySQL Unique index

It helps to maintain data integrity to enforce the uniqueness of values in one or more columns. We can create more than one UNIQUE index in a single table, which...

3 minutes read.

MySQL String Function

The string function is used to maintain and operate string values. This function modifies the string data as per function. We can do the concatenation, conversion, removal and replacing the...

4 minutes read.

MySQL FIELD() function

In this context, we will learn how we can use the MySQL FIELD() function with proper syntax and good examples. Introduction of MySQL FIELD() function The index position of a mentioned value...

3 minutes read.

MySQL function

MySQL function is a piece of program to perform some specific task. Here we pass a parameter and then return a single value. MySQL function mainly supports string, numeric, conditional,...

9 minutes read.

MySQL SELF JOIN

This join links table with itself. The inner join, a self join, a right join, and a cross join are connected with two or more two tables. But, the "self...

4 minutes read.

MySQL Union

MySQL contains the same categories of data in a different table. Sometimes, you require multiple tables to collect data together. MySQL union is a function to combine two table's data...

5 minutes read.

MySQL Invisible Index

Invisible Index MySQL index decides an option to the availability of the index for the query optimizer. This index shows the visible and invisible options to displays the index column in...

3 minutes read.

MySQL Operators

MySQL Operators MySQL operator needs advanced operation on the table and its data. This operator works with the "WHERE" clause. MySQL operators are a statement to modify information. It helps to...

13 minutes read.

MySQL LOG10() function

In this context, we will learn how we can use the MySQL LOG10() function with proper syntax and good examples. Introduction of MySQL LOG10() function To evaluate the natural logarithmic value of...

2 minutes read.

MySQL HEX() function

In this context, we will learn how we can use the MySQL HEX() function with proper syntax and good examples. Introduction of MySQL HEX() function For returning an equivalent hexadecimal string value...

3 minutes read.

MySQL NOW() function

In this context, we will learn how we can use the MySQL NOW() function with proper syntax and good examples. Introduction of MySQL NOW() function Basically, in MySQL, this function is used...

2 minutes read.

MySQL Environmental Setup

The MySQL Environmental Setup MySQL is free, open-source, and cross-platform software, which can be downloaded from its official website. MySQL management system installs on Linux, macOS, and windows. MySQL requires a framework...

6 minutes read.

MySQL Index

An index is a widely used method to access table information quickly. MySQL requires an index for operating table data stored in rows and columns. It's an entry point of...

3 minutes read.

MySQL View

Introduction MySQL View is a virtual table to create a clone of the base table. The View does not contain its values or data. MySQL View creates to connect more than...

12 minutes read.

MySQL INSERT() Function

In this context, we will learn how we can use the MySQL INSERT() function with proper syntax and good examples. Introduction of MySQL INSERT() function Basically, in MySQL, the INSERT function is...

2 minutes read.

MySQL Join

The relational database system needs to interconnect multiple tables with each other. MySQL is a popular and easy data management system to connect multiple tables. The foreign key is used...

5 minutes read.

MySQL ELT() function

In this context, we will learn how we can use the MySQL ELT() function with proper syntax and good examples. Introduction of MySQL ELT() function In the ELT function, the number field...

2 minutes read.

MySQL AVG function

This function works on numerical data type values. The average function shows the average value of the data set. If an average function returns a null value, then the row...

5 minutes read.

MySQL RAND() function

In this context, we will learn how we can use the MySQL RAND() function with proper syntax and good examples. Introduction of MySQL RAND() function Basically, in MySQL the RAND() function is...

3 minutes read.

MySQL Drop Index

Sometimes we have an index that is not required in data operations. In that case, we can use this statement to remove an existing index from the table. We can...

4 minutes read.