×

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 Command line client Basic Queries

MySQL – command line client Basic Queries There are many queries to work with the MySQL command-line client. Today, we will explore MySQL basic queries and their function. The MySQL query...

8 minutes read.

MySQL DELETE JOIN

Sometimes join becomes complicated and unwanted. In such cases, we can delete the unwanted joins in the tables. You can delete inner join, left join, right join as per requirement....

3 minutes read.

MySQL RPAD() function

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

2 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 LN() function

In this context, we will learn how we can use the MySQL LN() function with proper syntax and good examples. Introduction of MySQL LN() function For evaluation of the natural logarithm of...

2 minutes read.

MySQL database queries

MySQL database queries Database queries help to create, use, show and, delete the database. A Database is a collection of several tables and data. The database uses SQL language to perform...

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 POWER() function

In this context, we will learn how we can use the MySQL POWER() function with proper syntax and good examples. Introduction of MySQL POWER() function The value of a number raised to...

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 Advance table Query

MySQL Advance table Query The table is created by index, rows, and columns in the MySQL database. The user saves their information in matrix format. The database requires a query to...

14 minutes read.

MySQL SUM function

The SUM() function displays the total addition of the table values. It supports the arithmetic operation of the column values. This function does not return a null value. Here, the...

5 minutes read.

MySQL TAN() Function

Basically, the TAN() function in MySQL is used to give back the tangent of a mentioned number.In any kind of right-angle triangle, the tangent of an angle is the length...

2 minutes read.

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.

find_in_set() function in MySQL

This Function is used for finding the position of a particular string from the list of strings. For suppose if the specified string is repeated multiple times, then this functions...

4 minutes read.

MySQL Database Introduction

MySQL - Database Introduction: The database plays an essential role in MySQL for storing and modifying the data. The database creates and keeps multiple tables. The database organizes and manipulates...

8 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 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 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 COUNT function

The count function returns the number of rows in the table. This function shows either the entire rows count or the required row count of the table. It determines the...

5 minutes read.

MySQL RIGHT() Function

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

3 minutes read.