嗨,现在我在mysql中有2个表。

1.表-答案具有属性和价值

    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.表-标准具有属性和价值

       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

如何为此创建查询?

最佳答案

查询。

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

10-06 12:51