【问题标题】:I need to select where Condition this我需要选择 Condition this
【发布时间】:2019-10-02 02:30:13
【问题描述】:

我在 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 - Criterion 有属性和值

       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

我如何为此创建查询?

【问题讨论】:

标签: mysql sql codeigniter


【解决方案1】:

查询。

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

【讨论】:

  • 也应用到 CodeIgniter
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-02-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多