I already create a function called calculate_marks(user_id) and it run properly, but when i put in the insert statement, it will keep running in mysql and no respond, anyone know what is the problem?
INSERT INTO `marks`
(`marks_user_id`, `marks_addtime`, `marks_amount`
)
SELECT `user_id`, UNIX_TIMESTAMP(),
(SELECT calculate_marks(`user_id`))
FROM `user`
WHERE `user`.`user_status` = 'A';
It will return the result that i want if i run this
SELECT `user_id`, (SELECT calculate_marks(`user_id`))
FROM `user`
WHERE `user`.`user_status` = 'A';
Insert.. Selectstatement. Refer: dev.mysql.com/doc/refman/8.0/en/insert-select.html