0

I have wrote mysql query to update column using mysql variable. Actually I'm want to create the function, execute it and then drop the function for below query. I'm really new to mysql Function, Can some please help me to covert query into mySQL Function.

SET @user_id = 1;
SET @user_employee_id_new = '87847894';
SET @user_employee_id_old = '35345642';
select * from `user` WHERE (`employee` = @user_employee_id_new);
select @user_id = id from `user` WHERE (`employee` = @user_employee_id_old);
UPDATE `user` SET `employee` = @user_employee_id_new WHERE id = @user_id;

Appreciate it. Thanks!

happy
  • 17
  • 1
  • 1
  • 2
  • a function is used , when you need to make computations repeatedly, so you write it once and use it for ever – nbk Oct 16 '20 at 17:34
  • It seems you need simple ```UPDATE user SET employee=87847894 WHERE employee=35345642;```... – Akina Oct 16 '20 at 18:01

0 Answers0