質問編集履歴
3
Controllerの誤りを修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,11 +32,7 @@
|
|
32
32
|
|
33
33
|
});
|
34
34
|
|
35
|
-
$result = $result ->orderBy('table_a.updated_at', 'desc')
|
36
|
-
|
37
|
-
->take(10)
|
38
|
-
|
39
|
-
|
35
|
+
$result = $result ->get();
|
40
36
|
|
41
37
|
```
|
42
38
|
|
2
テーブル追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -53,3 +53,37 @@
|
|
53
53
|
userid` = table_b.userid)",
|
54
54
|
|
55
55
|
```
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
●table_a:ユーザテーブル
|
60
|
+
|
61
|
+
|userID|Name|
|
62
|
+
|
63
|
+
|:--|:--:|
|
64
|
+
|
65
|
+
|1|userA|
|
66
|
+
|
67
|
+
|2|userB|
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
●table_b:評価テーブル
|
72
|
+
|
73
|
+
|userID|Data|
|
74
|
+
|
75
|
+
|:--|:--:|
|
76
|
+
|
77
|
+
|1|1|
|
78
|
+
|
79
|
+
|1|5|
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
●期待するクエリ回答
|
86
|
+
|
87
|
+
1,userA,3
|
88
|
+
|
89
|
+
2,userB,null
|
1
エラーも追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,10 +32,24 @@
|
|
32
32
|
|
33
33
|
});
|
34
34
|
|
35
|
-
$l
|
35
|
+
$result = $result ->orderBy('table_a.updated_at', 'desc')
|
36
36
|
|
37
37
|
->take(10)
|
38
38
|
|
39
39
|
->get();
|
40
40
|
|
41
41
|
```
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
```php
|
48
|
+
|
49
|
+
"message": "SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to you
|
50
|
+
|
51
|
+
r MySQL server version for the right syntax to use near 'on `table_a`.`userid` = ?' at line 1 (SQL: select avg(`data`) as aggregate on `table_a`.`
|
52
|
+
|
53
|
+
userid` = table_b.userid)",
|
54
|
+
|
55
|
+
```
|