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 :)

ความคิดเห็น • 18

  • @omarykitenge8283
    @omarykitenge8283 2 ปีที่แล้ว +1

    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...

  • @sosmanoriginal7048
    @sosmanoriginal7048 2 ปีที่แล้ว +2

    You're the best, you showed the exact loop statement that I needed, thank you!

  • @maragee8
    @maragee8 2 ปีที่แล้ว

    I finally figured out the cursor syntax. Thanks for this video

  • @sherabpereira382
    @sherabpereira382 4 ปีที่แล้ว +1

    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.

  • @computerlearningbyargusaca5217
    @computerlearningbyargusaca5217 4 ปีที่แล้ว

    🙏🙏Very helpful and 👍👍well 😍😍made video for learning

  • @prabhuk1448
    @prabhuk1448 ปีที่แล้ว

    How to use nested cursor ..please tell me

  • @Joseph-yl6rc
    @Joseph-yl6rc 4 ปีที่แล้ว

    AMAZING SIR

  • @youcefkebir9131
    @youcefkebir9131 4 ปีที่แล้ว +1

    thank you sir you helped me a lot!

  • @TestingDuniya
    @TestingDuniya 5 ปีที่แล้ว +1

    Useful upload sir

  • @mohammedabbassayed5016
    @mohammedabbassayed5016 ปีที่แล้ว +1

    bro is speaking in ASMR voice😂😂

  • @anjanakr4381
    @anjanakr4381 3 ปีที่แล้ว

    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?

  • @ajinzrathod
    @ajinzrathod 4 ปีที่แล้ว +1

    Nice video.. thank you.. plz work on your accent sir

    • @OnlineWebTutor
      @OnlineWebTutor  4 ปีที่แล้ว

      Thanks, I will try my best. You can check the latest uploads.