I am having some difficulty getting a pretty simple stored procedure right. Consider the following article table snippet:
id replaced_by baseID
1
From mysql :
If the query returns no rows, a warning with error code 1329 occurs (No data), and the variable values remain unchanged
So you have an infinite loop when no records found with a given x (y remains unchanged)
Try SET y = (SELECT id ....) instead or add SET y = null before your select statement (it should be the first statement in the loop)