我正在尝试向我的表中插入我的选择查询的平均值,但我遇到了错误
这是我的问题:
INSERT INTO tbl_average(student_id, first_avg) VALUES
('100', AVG(SELECT fir_grad FROM tbl_grade
WHERE student_id='100' AND school_year='2015-2016'))
请帮助
答案 0 :(得分:1)
使用INSERT INTO SELECT
语法:
INSERT INTO tbl_average(student_id, first_avg)
SELECT 100, AVG(fir_grad)
FROM tbl_grade
WHERE student_id=100 AND school_year='2015-2016'