質問編集履歴
1
みほんのテーブル2つを生成するSQLを追記。コードの言語がSQLと記載。
title
CHANGED
File without changes
|
body
CHANGED
@@ -37,15 +37,34 @@
|
|
37
37
|
is_reliable=1の中では、A_IDに重複するものがないことがわかっています。
|
38
38
|
|
39
39
|
下記のようなSQLを書いて解決したいです。
|
40
|
-
```
|
40
|
+
```sql
|
41
41
|
update tableB
|
42
42
|
set answer = (ここになにか入る);
|
43
43
|
```
|
44
44
|
というところまでしかわかりません…。
|
45
45
|
|
46
|
-
```
|
46
|
+
```sql
|
47
47
|
select * from tableA join tableB on tableA.ID = tableB.A_ID where tableB.is_reliable=0;
|
48
48
|
```
|
49
49
|
というselect文は書けたので、これをupdateにうまく組み込むのだと思うのですが……。
|
50
50
|
|
51
|
-
アドバイスいただけたらと思います!
|
51
|
+
アドバイスいただけたらと思います!
|
52
|
+
|
53
|
+
以下、みほんのテーブル2つを生成するSQLです。
|
54
|
+
|
55
|
+
```sql
|
56
|
+
drop table if exists tableA;
|
57
|
+
create table tableA(ID, answer);
|
58
|
+
insert into tableA values(1, "A");
|
59
|
+
insert into tableA values(2, "B");
|
60
|
+
insert into tableA values(3, "C");
|
61
|
+
insert into tableA values(4, "D");
|
62
|
+
insert into tableA values(5, "E");
|
63
|
+
drop table if exists tableB;
|
64
|
+
create table tableB(ID, A_ID, answer, is_reliable);
|
65
|
+
insert into tableB values(1, 1, "ABC", 1);
|
66
|
+
insert into tableB values(2, 1, "BCD", 0);
|
67
|
+
insert into tableB values(3, 2, "CDE", 1);
|
68
|
+
insert into tableB values(4, 3, "DEF", 1);
|
69
|
+
insert into tableB values(5, 4, "EFG", 0);
|
70
|
+
```
|