I use a function with MySQL to change the password, but the AND statement does not work correctly.
CREATE DEFINER = 'root'@'%' FUNCTION temp_staff.fn_changePassword(user_id INT, oldPassword VARCHAR(255), newPassword VARCHAR(255)) RETURNS int(11) BEGIN update temp_staff.tbl_user set password = newPassword WHERE user_id = user_id AND password = oldPassword; RETURN 1; END
Result: it fetches 3 rows, but in my table user_id is the primary key, so give me the correct solution.
source share