質問編集履歴
4
訂正、うまくできました
test
CHANGED
File without changes
|
test
CHANGED
@@ -132,26 +132,6 @@
|
|
132
132
|
|
133
133
|
|
134
134
|
|
135
|
-
```SQLite
|
136
|
-
|
137
|
-
/* 応答がなくなり、ハングアップ状態 */
|
138
|
-
|
139
|
-
UPDATE contract
|
140
|
-
|
141
|
-
SET count = (
|
142
|
-
|
143
|
-
SELECT MAX(b.bill_count)+1
|
144
|
-
|
145
|
-
FROM bill as b
|
146
|
-
|
147
|
-
WHERE contract.id = b.contract_id
|
148
|
-
|
149
|
-
)
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
```
|
154
|
-
|
155
135
|
|
156
136
|
|
157
137
|
```SQLite
|
3
試したことを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -134,6 +134,28 @@
|
|
134
134
|
|
135
135
|
```SQLite
|
136
136
|
|
137
|
+
/* 応答がなくなり、ハングアップ状態 */
|
138
|
+
|
139
|
+
UPDATE contract
|
140
|
+
|
141
|
+
SET count = (
|
142
|
+
|
143
|
+
SELECT MAX(b.bill_count)+1
|
144
|
+
|
145
|
+
FROM bill as b
|
146
|
+
|
147
|
+
WHERE contract.id = b.contract_id
|
148
|
+
|
149
|
+
)
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
```
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
```SQLite
|
158
|
+
|
137
159
|
/* Error no such column: b.contract_id */
|
138
160
|
|
139
161
|
UPDATE contract
|
2
試してみたクエリー
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,7 +26,7 @@
|
|
26
26
|
|
27
27
|
アップデートのため下記のようなSQLを書きました
|
28
28
|
|
29
|
-
```
|
29
|
+
```SQLite
|
30
30
|
|
31
31
|
UPDATE c
|
32
32
|
|
@@ -52,7 +52,7 @@
|
|
52
52
|
|
53
53
|
selectによる表示は目的通り出力されます
|
54
54
|
|
55
|
-
```SQL
|
55
|
+
```SQLite
|
56
56
|
|
57
57
|
SELECT c.*,MAX(b.bill_count)+1
|
58
58
|
|
@@ -73,3 +73,85 @@
|
|
73
73
|
FROM周辺に問題があるようなのですが、どのように修正すればよいか分からずにいます。
|
74
74
|
|
75
75
|
よろしくおねがいします。
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
==追記(他に試した方法)==
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
```SQLite
|
84
|
+
|
85
|
+
/* 同じデータで埋められてしまいます */
|
86
|
+
|
87
|
+
UPDATE contract
|
88
|
+
|
89
|
+
SET count = (
|
90
|
+
|
91
|
+
SELECT MAX(b.bill_count)+1
|
92
|
+
|
93
|
+
FROM contract as c
|
94
|
+
|
95
|
+
LEFT JOIN bill as b
|
96
|
+
|
97
|
+
ON c.id = b.contract_id
|
98
|
+
|
99
|
+
WHERE c.status <> '1'
|
100
|
+
|
101
|
+
GROUP BY b.contract_id
|
102
|
+
|
103
|
+
)
|
104
|
+
|
105
|
+
```
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
```SQLite
|
110
|
+
|
111
|
+
/* 応答がなくなり、ハングアップ状態 */
|
112
|
+
|
113
|
+
UPDATE contract
|
114
|
+
|
115
|
+
SET count = (
|
116
|
+
|
117
|
+
SELECT MAX(b.bill_count)+1
|
118
|
+
|
119
|
+
FROM contract as c
|
120
|
+
|
121
|
+
LEFT JOIN bill as b
|
122
|
+
|
123
|
+
ON c.id = b.contract_id
|
124
|
+
|
125
|
+
WHERE contract.id = b.contract_id
|
126
|
+
|
127
|
+
GROUP BY b.contract_id
|
128
|
+
|
129
|
+
)
|
130
|
+
|
131
|
+
```
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
```SQLite
|
136
|
+
|
137
|
+
/* Error no such column: b.contract_id */
|
138
|
+
|
139
|
+
UPDATE contract
|
140
|
+
|
141
|
+
SET count =
|
142
|
+
|
143
|
+
(
|
144
|
+
|
145
|
+
SELECT MAX(b.bill_count)+1
|
146
|
+
|
147
|
+
FROM bill as b
|
148
|
+
|
149
|
+
GROUP BY b.contract_id
|
150
|
+
|
151
|
+
)
|
152
|
+
|
153
|
+
WHERE id = b.contract_id
|
154
|
+
|
155
|
+
/* b.contract_id を bill.contract_id にするとエラーは bill.contract_id */
|
156
|
+
|
157
|
+
```
|
1
誤字の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,7 +30,7 @@
|
|
30
30
|
|
31
31
|
UPDATE c
|
32
32
|
|
33
|
-
SET count = MAX(
|
33
|
+
SET count = MAX(b.bill_count)+1
|
34
34
|
|
35
35
|
FROM contract AS c
|
36
36
|
|