我有這些表:CROSS JOIN左連接數排
任務組表
id name 1 cooking 2 baking
任務狀態表
id name 1 open 2 done? 3 completed 4 re-open 5 suspend
任務表
project_id task_group_id task_status_id task_name 1 1 1 cooking martabak 1 1 2 cooking sate kambing 1 1 3 cooking nasi uduk 1 1 4 cooking nasi goreng 1 1 1 cooking martabak telor 1 1 2 cooking sate ayam 1 1 5 cooking nasi tutug oncom 1 1 5 cooking nasi pera 1 2 1 bake nastar 1 2 2 bake bolu pisang 1 2 3 bake bika ambon 1 2 5 bake bolu kukus 1 2 3 bake cheese stik 1 2 1 bake bolu ketan 1 2 5 bake papais 1 2 1 bake boled
和結果我想是這樣的:
project task_group task_status number Restaurant Cooking Completed 1 Restaurant Cooking Done? 2 Restaurant Cooking Open 2 Restaurant Cooking Re-open 1 Restaurant Baking Completed 2 Restaurant Baking Done? 1 Restaurant Baking Open 3 Restaurant Baking Re-open 0
任務狀態 「暫停」 被排除
我已經嘗試過加入任務帶有任務狀態表的子表(使用where子句中的task_status.name('open','done?','completed','re-open')),但是我不能得到正確的計數聚集
只需按第一表名和第二表名 –
我已經嘗試過了,但計數結果是不正確...我確定我錯過了加入的鏈接,但我不知道我是如何加入它的... – Rakaziwi