
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Combine SELECT & 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)
- Related Articles
- Combine INSERT, VALUES, and SELECT in MySQL
- Show constraints on table command in MySQL?
- Show MySQL host via SQL Command?
- Limit length of longtext field in MySQL SELECT results?
- MySQL SELECT to skip first N results?\n
- Print structured MySQL SELECT at command prompt
- Show column value twice in MySQL Select?
- Best way to combine multiple advanced MySQL select queries?
- Does SELECT TOP command exist in MySQL to select limited number of records?
- Select results from the middle of a sorted list in MySQL?
- Select * but ignore displaying results containing a specific character in MySQL
- MySQL Select Date Equal to Today and return results for the same date?
- Insert the results of a MySQL select? Is it possible?
- What does 'show processlist' command do in MySQL?
- Explain Select command in DBMS

Advertisements