嗨,我现在在mysql中有2个表。
1.Table-答案具有属性和值
Id_Answer Id_Form Result Total Average
-------------------------------------------------------------------------------
13 1 ["2","3","1","3","1","1","2","3"] 16 2.00
15 1 ["2","2","1","3","0","2","1","0"] 11 1.38
2.Table-条件具有属性和值
Id_Criterion . Id_Form . Topic Min . Max . Detail
-------------------------------------------------------------------------------------------
1 1 Good person 1.5 2 You is a Good person
2 1 Bad person 0 1.4 You is a bad
我需要获取Critetion.Topic,Critetion.Mix,Critetion.Min,Critetion.Max,Critetion.Detail
我将使用Answer.Average来比较In Criterion.Min和Criterion.Max和Answer.Id_Form = Criterion.Id_Form
如何为此创建查询?
答案 0 :(得分:0)
查询。
select b.Topic, b.Min, b.Max, b.Detail
from Answer a
inner join Criterion b
on a.Id_Form = b.Id_Form and a.Average between b.Min and b.Max