
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Combine SELECT and SHOW Command Results in MySQL
To combine SELECT and SHOW command results into one, use the below query −
select @anyVariableName1 as anyAliasName1,@anyVariableName1 as anyAliasName2,......N;
To combine the SELECT and SHOW, first create and initialize the first variable. Following is the query −
mysql> set @first_name='John'; Query OK, 0 rows affected (0.00 sec)
To combine the SELECT and SHOW, create and initialize the second variable. Following is the query −
mysql> set @last_name='Smith'; Query OK, 0 rows affected (0.00 sec)
Following is the query to combine the SELECT and SHOW command −
mysql> select @first_name as EmployeeFirstName,@last_name as EmployeeLastName;
This will produce the following output −
+-------------------+------------------+ | EmployeeFirstName | EmployeeLastName | +-------------------+------------------+ | John | Smith | +-------------------+------------------+ 1 row in set (0.00 sec)
In order to combine system global variables, you can use @@ instead of single one(@). The below query will combine current MySQL version and port number.
Following is the query −
mysql> select @@version as CURRENT_MYSQL_VERSION,@@port as CURRENT_MYSQL_PORT_NUMBER;
This will produce the following output −
+-----------------------+---------------------------+ | CURRENT_MYSQL_VERSION | CURRENT_MYSQL_PORT_NUMBER | +-----------------------+---------------------------+ | 8.0.21 | 3306 | +-----------------------+---------------------------+ 1 row in set (0.00 sec)
Advertisements