

- 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 I return the values of columns from MySQL table as a set of values?
With the help of MySQL MAKE_SET() function, we can return the values of columns from MySQL table as a set of values. To understand it, we are taking the example of Student_Name table which has the following data −
mysql> Select * from Student_Name; +---------+-------+---------+ | FName | Mname | Lname | +---------+-------+---------+ | Rahul | NULL | Singh | | Gaurav | Kumar | NULL | | Harshit | NULL | Khurana | | Yash | Pal | Sharma | +---------+-------+---------+ 4 rows in set (0.00 sec)
Now, suppose if we want to make the set of ‘Fname’ and ‘Lname’ column’s values then the following query will do it −
mysql> Select MAKE_SET(1|4,fname,mname,lname)AS '(Fname,Lname)' from Student_name; +-----------------+ | (Fname,Lname) | +-----------------+ | Rahul,Singh | | Gaurav | | Harshit,Khurana | | Yash,Sharma | +-----------------+ 4 rows in set (0.00 sec)
- Related Questions & Answers
- How can we add values into the columns of a MySQL table?
- How can we combine the values of two or more columns of MySQL table?
- How can I search within a table of comma-separated values in MySQL?
- Populate null columns in a MySQL table and set values
- How can we list all the columns of a MySQL view as we can list the columns of a MySQL table?
- How can I create a stored procedure to delete values from a MySQL table?
- Add values of two columns considering NULL values as zero in MySQL
- How can we update the values in one MySQL table by using the values of another MySQL table?
- How can I create a MySQL stored procedure that returns multiple values from a MySQL table?
- Set DEFAULT values for columns while creating a table in MySQL
- How do I select data from one table only where column values from that table match the column values of another table in MySQL?
- How can I search data from MySQL table based on similar sound values?
- How can we get randomly different set of rows or values each time from MySQL table?
- How can I create a stored procedure to select values on the basis of some conditions from a MySQL table?
- How can I update MySQL table after quoting the values of a column with a single quote?
Advertisements