How to skip to next iteration if no results are returned in SELECT statement in Stored Procedure
You shoud use: LEAVE loop_name

IF NOT EXIST (SELECT 1 FROM table3 WHERE &lt;some condition&gt;)
    LEAVE read_loop;