gpt4 book ai didi

mysql - SQL操作数执行单行、列

转载 作者:行者123 更新时间:2023-11-29 10:44:06 25 4
gpt4 key购买 nike

enter image description here 我的sql查询:-

SELECT 
(s.Mark*0.8+((i.OutOf)*sum(i.Mark)/9000)+((ai.OutOf)*sum(ai.Mark) /180)+a.Mark)
AS final
from mark_semester s,
mark_assignment ai,
mark_internaltest i,
mark_attendance a,
master_student ms
WHERE s.SubjectId=i.SubjectId and
s.SubjectId=ai.SubjectId
and s.SubjectId=a.SubjectId
and s.SubjectId='1'
AND s.RegNo=i.RegNo
and s.RegNo=ai.RegNo
and s.RegNo=a.RegNo
and s.RegNo=ms.RegNo
and s.RegNo='100'
and s.Semester=i.Semester
and s.Semester=ai.Semester
and s.Semester=a.Semester
and s.Semester='1'

在此查询中,我想输入多个subjectidregnos来获取数据
谁能帮我解决这个问题。

最佳答案

您可以使用 IN MySQL 运算符来处理多个 SubjectIdRegNo,如下所示:

SELECT (s.Mark*0.8+((i.OutOf)*sum(i.Mark)/9000)+((ai.OutOf)*sum(ai.Mark)/180)+a.Mark) AS final
from mark_semester s
join mark_assignment ai on s.SubjectId=ai.SubjectId
join mark_internaltest i on s.SubjectId=i.SubjectId
join mark_attendance a on s.SubjectId=a.SubjectId
join master_student ms on s.RegNo=ms.RegNo
WHERE
s.SubjectId in ('1','2') AND
s.RegNo in ('100','101') and
s.Semester='1'

关于mysql - SQL操作数执行单行、列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44947006/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com