

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can we fetch a MySQL SET column as a list of integer offset?
<p style="">We can fetch the MySQL SET column values as a list of integer offset with the help of the MAKE_SET() function. To make it understand, we are creating a table named ‘set_testing’ as follows −</p><pre class="prettyprint notranslate">mysql> Create table set_testing( id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, table SET('ABC','ABD','GHF') NOT NULL); Query OK, 0 rows affected (0.08 sec) mysql> Insert into set_testing (table) values('1'); Query OK, 1 row affected (0.06 sec) mysql> Insert into set_testing (table) values('2'); Query OK, 1 row affected (0.06 sec) mysql> Insert into set_testing (table) values('3'); Query OK, 1 row affected (0.02 sec) mysql> Insert into set_testing (table) values('4'); Query OK, 1 row affected (0.02 sec) mysql> Select * from set_testing; +----+---------+ | id | table | +----+---------+ | 1 | ABC | | 2 | ABD | | 3 | ABC,ABD | | 4 | GHF | +----+---------+ 4 rows in set (0.00 sec)</pre><p style="">Now, the following query will fetch the MySQL SET column as a list of integer offset −</p><pre class="prettyprint notranslate">mysql> Select MAKE_SET(types+0,'1','2','3') as output from doctypes1; +--------+ | output | +--------+ | 1 | | 2 | | 1,2 | | 3 | +--------+ 4 rows in set (0.00 sec)</pre>
- Related Questions & Answers
- How can we fetch a particular row as output from a MySQL table?
- How can we list all the columns of a MySQL view as we can list the columns of a MySQL table?
- How can we fetch one or more columns as output from a MySQL table?
- Can we use MySQL keyword as alias name for a column?
- How can we get only unique values of a column in MySQL result set?
- How can we create MySQL views with column list?
- How can we get the structure of a MySQL view as we can get the structure of a MySQL table?
- How can we get the definition of a MySQL view as we can get the definition of a MySQL table?
- In MySQL, how can we represent the time value as an integer?
- How can we get the summary output of a column in MySQL result set itself?
- Can we use “year” as a column came in a MySQL Table?
- How can we fetch a second highest salary of an employee from a MySQL table?
- Can we use semicolon as a MySQL DEMILITER?
- How can we remove a column from MySQL table?
- How can we create MySQL views without any column list?
Advertisements