情景:
Table1的字段名称命名为testtable
id,名称,大小,宽度,高度
Table2的字段名称命名为errortable
id,desc,field1,field2,operator
错误的值
+----+-------------------------------------+--------+--------+----------+
| id | desc | field1 | field2 | operator |
+----+-------------------------------------+--------+--------+----------+
| 1 | size should not greater than width | size | width | > |
| 2 | size should not greater than height | size | height | > |
| 3 | with should be equal to height | width | height | <> |
+----+-------------------------------------+--------+--------+----------+
现在我想从testtable中查看:
统计所有大小&gt;的记录宽度
统计所有大小&gt;的记录高度
计算宽度&lt;&gt;的所有记录高度。
所需输出
+-------------------------------------+-------+
| errorname | count |
+-------------------------------------+-------+
| size should not greater than width | 6 |
| size should not greater than height | 2 |
| with should be equal to height | 3 |
+-------------------------------------+-------+
可以这样做吗?
当前查询:
选择desc,(从testtable中选择count(*)为“Total Errors”,其中errortable.field1 errortable.operator errortable.field2)来自errortable group by id
答案 0 :(得分:0)
感谢所有评论的人,我在你的评论中得到了我的答案,并通过在php中处理一些代码来实现这个场景。