我使用以下 mysql 查询来选择所有选定的信息,其中学生表的学生 ID 不存在于成本分摊表中,但我遇到了错误。
有什么帮助吗?提前致谢!
select st.id as 'Student ID', st.stud_fname as 'First Name', st.stud_lname as 'Last Name', st.stud_middle_name as 'Middle Name',
dp.dep_name as 'Department',dp.max_dur_year as 'Max Duration', st.entry_year as 'Entry',MAX(sc.acc_year) as 'Current Academic Year',
sum(sc.Tuition_fee+sc.Accomod_fee+sc.Food_fee) as 'Total Cost Sharing'
from student st left JOIN student_costsharing sc on st.id = sc.stud_id
left join department dp on st.dep_id=dp.id
where st.id not in ( SELECT *
FROM student_costsharing
WHERE sc.stud_id=st.id
)
GROUP BY st.stud_fname
order by st.stud_fname
错误信息:
1241 - Operand should contain 1 column(s)
您需要在 IN
子句中指定列,而不是使用 *
where st.id not in ( SELECT stud_id
FROM student_costsharing
WHERE sc.stud_id=st.id
)
我是一名优秀的程序员,十分优秀!