
- 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
MySQL procedure to display a “select” statement twice
To understand, let us create a stored procedure. Here, we have 2 select statements in the stored procedure −
mysql> DELIMITER // mysql> CREATE PROCEDURE select_statement() -> BEGIN -> SELECT "HI" AS `FIRST VALUE`; -> SELECT "HELLO" AS `SECOND VALUE`; -> END -> // Query OK, 0 rows affected (0.09 sec) mysql> DELIMITER ;
Call the stored procedure using CALL command −
mysql> CALL select_statement();
This will produce the following output −
+-------------+ | FIRST VALUE | +-------------+ | HI | +-------------+ 1 row in set (0.00 sec) +--------------+ | SECOND VALUE | +--------------+ | HELLO | +--------------+ 1 row in set (0.01 sec) Query OK, 0 rows affected (0.01 sec)
- Related Articles
- How to call a stored procedure using select statement in MySQL?
- How to set two variables in a stored procedure with a single MySQL select statement?
- MySQL case statement inside a select statement?
- Display description of MySQL stored procedure
- Show column value twice in MySQL Select?
- MySQL procedure with SELECT to return the entire table
- IF() function in a MySQL Select statement?
- Display table records from a stored procedure in MySQL
- Storing value from a MySQL SELECT statement to a variable?
- How to correctly implement END IF statement in a MySQL Stored Procedure?
- How to use a select statement while updating in MySQL?
- How to use NULL in MySQL SELECT statement?
- MySQL SELECT IF statement with OR?
- How MySQL IF statement can be used in a stored procedure?
- How Can MySQL LOOP statement be used in a stored procedure?

Advertisements