- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 to select return value from MySQL prepared statement?
Let us create a stored procedure and select return value from MySQL prepared statement −
mysql> DELIMITER // mysql> CREATE PROCEDURE return_value() -> BEGIN -> SET @returnQuery= 'SELECT 98 INTO @value'; -> PREPARE stmt FROM @returnQuery; -> EXECUTE stmt; -> END -> // Query OK, 0 rows affected (0.20 sec) mysql> DELIMITER ;
Call stored procedure using CALL command.
mysql> call return_value(); Query OK, 1 row affected (0.07 sec)
Display value using select statement −
mysql> select @value;
output
This will produce the following output −
+--------+ | @value | +--------+ | 98 | +--------+ 1 row in set (0.00 sec)
- Related Articles
- How to use prepared statement for select query in Java with MySQL?
- Storing value from a MySQL SELECT statement to a variable?
- Change value from 1 to Y in MySQL Select Statement?
- Change value from 1 to Y in MySQL Select Statement using CASE?
- Assign an SQL result to variable from prepared statement in MySQL?
- How to use NULL in MySQL SELECT statement?
- How to select distinct value from one MySQL column only?
- How to create Tab Delimited Select statement in MySQL?
- Using Prepared statement correctly with WHERE condition in case of any value in MySQL Java
- MySQL case statement inside a select statement?
- How to replace values of select return in MySQL?
- How to select unique value in MySQL?
- How to use a select statement while updating in MySQL?
- Return maximum value from records in MySQL
- Using the value of an alias inside the same MySQL SELECT statement

Advertisements