MySQL Stored Procedure Beginners Tutorial #14 - Basics of Cursor in MySQL Stored Procedure | Cursor
ฝัง
- เผยแพร่เมื่อ 9 พ.ย. 2024
- In this video we'll see:
Basics of Cursor in MySQL Stored Procedure | Cursor
ABOUT MYSQL CURSOR
============================
MySQL cursor in stored procedures to iterate through a result set returned by a SELECT
statement.
To handle a result set inside a stored procedure, we use a cursor. A cursor allows you to
iterate a set of rows returned by a query and process each row accordingly.
SYNTAX TO FOLLOW TO USE CURSOR
==================
1. DECLARE cursor_name CURSOR FOR SELECT_statement;
2. OPEN cursor_name;
3. DECLARE CONTINUE HANDLER FOR NOT FOUND // termination statement
4. FETCH cursor_name INTO variables list;
5. CLOSE cursor_name;
Example:
BEGIN
DECLARE finished int default 0;
DECLARE emails_list varchar(500) default "";
DECLARE email varchar(50) default "";
DECLARE user_data CURSOR FOR SELECT email from tbl_users limit 5;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET finished = 1;
OPEN user_data;
get_user_email: LOOP
FETCH user_data INTO email;
IF finished = 1 THEN
LEAVE get_user_email;
END IF;
SET emails_list = CONCAT(emails_list,", ",email);
END LOOP get_user_email;
CLOSE user_data;
SELECT emails_list;
END
SOCIAL :
===============
Subscribe : / @onlinewebtutor
FACEBOOK : / onlinewebtutorhub
TWITTER: / owthub
BLOG: onlinewebtutor...
Other Tutorials
===============
Wordpress Customizations:
---------------------------------
Wordpress Theme (Hindi): goo.gl/MZ8maF
Wordpress Widget (Hindi): goo.gl/Dc2htn
Wordpress Plugin (English): goo.gl/BA7dYG
Wordpress Theme Options (English): goo.gl/Vjv3Ub
Wordpress JSON Rest API (English): goo.gl/SVQRQR
Wordpress JSON Rest API (Hindi): goo.gl/NNWfKa
and many more...
Javascript framework:
----------------------------------
Learn backbone.js here! (English) : goo.gl/Qd2Pcs
Learn Vue JS here ! (Hindi): goo.gl/MVtsmh
PHP Frameworks:
----------------------------------
Laravel tutorial (Hindi): goo.gl/Nh9qJk
CakePHP tutorial (Hindi): goo.gl/uRsS3G
Tags
----------------------------------
mysql stored procedure,
Stored Procedures - MySQL,
Stored Procedures in MySQL and PHP,
SQL Stored Procedures,
MySQL Stored Procedure Tutorial,
MySQL Stored Procedure & MySQL Functions Guide,
mysql stored procedure for beginners,
Beginners' guide to stored procedures with MySQL,
Getting Started with MySQL Stored Procedures,
mysql stored procedure development for beginners,
mysql stored procedure from scratch,
online web tutor mysql stored procedures,
online web tutor sanjay,
Thanks
Online Web Tutor
Keep learning and Sharing :)
You are among the best online trainers I have met, to me accent is not an issue as long as I understand. In fact I love your the accent, I bet many people understand these because of your accent, if you use slaying we could not understand...
Thank you
You're the best, you showed the exact loop statement that I needed, thank you!
Thank you
I finally figured out the cursor syntax. Thanks for this video
And.....if I click on go button... again have some error!? (With a very friendly voice) . You made my day sir! thanks for the good content.
You're welcome!
🙏🙏Very helpful and 👍👍well 😍😍made video for learning
How to use nested cursor ..please tell me
AMAZING SIR
thank you sir you helped me a lot!
Welcome
Useful upload sir
Thanks @Testing Duniya
bro is speaking in ASMR voice😂😂
Hi sir, I need to give values for IN in the sql select statement . Eg: "SELECT name from tbl_name where id IN(145,146)". So how can I give these values into the Select statement?
Nice video.. thank you.. plz work on your accent sir
Thanks, I will try my best. You can check the latest uploads.