I want to insert data to a table with values coming from 3 different tables
table class_teachers_section
class_ref teachers_ref section_ref
2 3 2
1 6 2
table class id name hours 1 pe 3
table teachers id first_name last_name 1 Lenovo Lenovo
table section id name 1 grade 4
class_teachers_section is a intermediary table ... here is my statement
INSERT INTO class_teachers_section(class_ref, teachers_ref, section_ref)
values (
(class_ref, (select class.id as class_ref from class where class.name = 'pe')),
(teachers_ref, (select teachers.id as teachers_ref from teachers where
teachers.last_name = 'lenevo')),
(section_ref, (select section.id as section_ref from section where section.name =
'grade 4'))
)
1241 - Operand should contain 1 column(s)
do you guys have any idea how to resolve this? thanks
tried this ..
INSERT INTO class_teachers_section(class_ref, teachers_ref, section_ref)
values( (select class.id as class_ref from class where class.name = 'pe'),
(select teachers.id as teachers_ref from teachers where teachers.last_name = 'lenevo'),
(select section.id as section_ref from section where section.name = 'grade 4'))
teachers_ref can not be null error