Php 论
我有很多桌子: 分组表一Php 论,php,sql,symfony1,doctrine,doctrine-1.2,Php,Sql,Symfony1,Doctrine,Doctrine 1.2,我有很多桌子: 分组表一 id | name 1 | GroupTableOne 2 | GroupTableTwo 3 | GroupTableThree 4 | GroupTableFour 表一 id | group_table_one_id | name 1 | 1 | tableOneOne 2 | 2 | tableOneTwo 3 | 3 | tableOneThr
id | name
1 | GroupTableOne
2 | GroupTableTwo
3 | GroupTableThree
4 | GroupTableFour
表一
id | group_table_one_id | name
1 | 1 | tableOneOne
2 | 2 | tableOneTwo
3 | 3 | tableOneThree
4 | 4 | tableOneFour
5 | 2 | tableOneFive
6 | 2 | tableOneSix
7 | 2 | tableOneSeven
表二
id | table_three_id | num | table_one_id
1 | 1 | 1 | 1
2 | 1 | 1 | 2
3 | 1 | 2 | 2
4 | 2 | 2 | 3
5 | 2 | 3 | 3
6 | 3 | 3 | 2
7 | 3 | 3 | 1
表三
id | num | test
1 | 1 | a
2 | 1 | a
3 | 1 | b
4 | 2 | b
5 | 2 | b
6 | 3 | c
7 | 3 | a
表四:
id | name
1 | dsfds
2 | sads
3 | asda
如果我要计算test.ThreeTable=$id的所有TableOne,我在OneTableTable.class中有一个查询:
这工作正常。
如何计算相同的值,但显示count GroupTableOne而不是TableOne
现在是每个名字的计数表。我想数一数每个名字
例如:
name tableOne | group | count
tableOneOne | 1 | 2
tableOneTwo | 2 | 2
tableOneThree | 3 | 1
tableOneFour | 4 | 4
tableOneFive | 2 | 3
tableOneSix | 2 | 1
tableOneSeven | 2 | 4
现在可以了,工作正常。我想为GroupTable求和*
例如,对于GroupTableTwo=tableOneTwo+tableOneFive+tableOneSix+tableOneSeven
:
如何修改对此的查询?最好我想要新的查询。谢谢你的帮助 嗨。。。我真的不明白你的问题。。。你能不能更详细地解释一下你想做什么,你到底需要什么?你想要一个SQL请求,还是像你的标题所暗示的那样一个条令请求。我不明白你是怎么计算的。请先粘贴代码。
name GroupTable | count
GroupTableOne | 2
GroupTableTwo | 10
GroupTableThree | 1
GroupTableFour | 4