回答編集履歴
1
追記
test
CHANGED
@@ -29,3 +29,37 @@
|
|
29
29
|
on usr.id = his.userid
|
30
30
|
|
31
31
|
```
|
32
|
+
|
33
|
+
projectから取得する項目が限定されるなら、いっそ以下の方が高速だと思います。
|
34
|
+
|
35
|
+
```SQL
|
36
|
+
|
37
|
+
select prj.*, usr.username
|
38
|
+
|
39
|
+
from (
|
40
|
+
|
41
|
+
select prj.id, prj.projectname
|
42
|
+
|
43
|
+
, max(his.updatedt) as lastupdate
|
44
|
+
|
45
|
+
from project as prj
|
46
|
+
|
47
|
+
left join history as his
|
48
|
+
|
49
|
+
on prj.id = his.projectid
|
50
|
+
|
51
|
+
group by prj.id, prj.projectname
|
52
|
+
|
53
|
+
) as prj
|
54
|
+
|
55
|
+
left join history as his
|
56
|
+
|
57
|
+
on prj.id = his.projectid
|
58
|
+
|
59
|
+
and prj.lastupdate=his.updatedt
|
60
|
+
|
61
|
+
left join user as usr
|
62
|
+
|
63
|
+
on usr.id = his.userid
|
64
|
+
|
65
|
+
```
|