I want to fetch data from student and teacher tables and insert into another table. but when I try to do that I am getting below error
@delimiter %%%;
BEGIN
DECLARE name CHAR (3);
DECLARE subject VARCHAR(25);
DECLARE ID DECIMAL(19,0);
DECLARE teacher_name VARCHAR(25);
insert into temp_table(std_name, subject, std_id, teacher_name) values (
SELECT std.name, std.subject, std.ID, tr.teacher_name FROM Student std inner join teacher tr on std.subject = tr.subject);
END%%%
@delimiter ;
%%%
Result
[Code: -811, SQL State: 21000] The result of a scalar fullselect, SELECT INTO statement, or VALUES INTO statement is more than one row.. SQLCODE=-811, SQLSTATE=21000, DRIVER=4.22.29