0
场景:命名为errortable我可以使用一个表字段值作为mysql select查询中的第二个表字段名吗?
ID,说明表2的名为TestTable的
ID,名称,规格,宽度表1的
字段名,高度
字段名,field1,field2,运营商
errortable的值
+----+-------------------------------------+--------+--------+----------+
| 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的检查:
统计所有那些记录,大小>宽度
统计所有那些记录,大小>高度
计数所有那些宽度为<>高度的记录。
所需的输出
+-------------------------------------+-------+
| errorname | count |
+-------------------------------------+-------+
| size should not greater than width | 6 |
| size should not greater than height | 2 |
| with should be equal to height | 3 |
+-------------------------------------+-------+
是可以做到这样吗?
当前查询:
选择递减,(SELECT COUNT(*)从TestTable的 “错误总数”,其中errortable.field1 errortable.operator errortable.field2)的ID从errortable组
MySQL还是Postgeslq?不要标记产品不参与... – jarlh
任何人,我需要在这两个 –
他们被称为__relational__数据库的原因是因为他们都是关于表之间的__relations__,但这两个表之间没有关系 –