Computer >> Computer tutorials >  >> Programming >> MySQL

How can we use MySQL EXPORT_SET() function with column of a table?


We can use EXPORT_SET() function with column of a table by providing integer type column as the first argument of this function. Following example will demonstrate it −

Example

mysql> SELECT Id, EXPORT_SET(id,'1','0',' ',5)AS 'ID in bits' from student;

+------+------------+
| Id   | ID in bits |
+------+------------+
| 1    | 1 0 0 0 0  |
| 2    | 0 1 0 0 0  |
| 15   | 1 1 1 1 0  |
| 20   | 0 0 1 0 1  |
| 21   | 1 0 1 0 1  |
+------+------------+

5 rows in set (0.00 sec)

Here we are using the column ‘Id’ of the table ‘Student’ as argument of EXPORT_SET() function.