回答編集履歴
1
追記
test
CHANGED
@@ -5,3 +5,91 @@
|
|
5
5
|
|
6
6
|
|
7
7
|
とありますが、company_t_map_accounts にはデータが1件もないので、SELECT されるデータは1件もないかと。
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
追記
|
14
|
+
|
15
|
+
Oracle での実行結果
|
16
|
+
|
17
|
+
```SQL
|
18
|
+
|
19
|
+
SQL> SET NULL null
|
20
|
+
|
21
|
+
SQL> SELECT
|
22
|
+
|
23
|
+
2 A.account_id
|
24
|
+
|
25
|
+
3 , C.group_account_id
|
26
|
+
|
27
|
+
4 FROM company_m_accounts A -- ※ Oracle ではここで AS は記述できない
|
28
|
+
|
29
|
+
5 LEFT OUTER JOIN company_t_map_accounts B -- ※
|
30
|
+
|
31
|
+
6 ON A.company_id = B.company_id
|
32
|
+
|
33
|
+
7 AND A.account_id = B.group_account_id
|
34
|
+
|
35
|
+
8 LEFT OUTER JOIN group_m_accounts C -- ※
|
36
|
+
|
37
|
+
9 ON B.group_id = C.group_id
|
38
|
+
|
39
|
+
10 AND A.account_id = B.group_account_id
|
40
|
+
|
41
|
+
11 WHERE A.company_id = 'com'
|
42
|
+
|
43
|
+
12 AND B.group_id = 'grp';
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
レコードが選択されませんでした。
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
SQL> -- AND B.group_id = 'grp' を削ると、
|
52
|
+
|
53
|
+
SQL> SELECT
|
54
|
+
|
55
|
+
2 A.account_id
|
56
|
+
|
57
|
+
3 , C.group_account_id
|
58
|
+
|
59
|
+
4 FROM company_m_accounts A
|
60
|
+
|
61
|
+
5 LEFT OUTER JOIN company_t_map_accounts B
|
62
|
+
|
63
|
+
6 ON A.company_id = B.company_id
|
64
|
+
|
65
|
+
7 AND A.account_id = B.group_account_id
|
66
|
+
|
67
|
+
8 LEFT OUTER JOIN group_m_accounts C
|
68
|
+
|
69
|
+
9 ON B.group_id = C.group_id
|
70
|
+
|
71
|
+
10 AND A.account_id = B.group_account_id
|
72
|
+
|
73
|
+
11 WHERE A.company_id = 'com';
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
ACCOUNT_ID GROUP_ACCO
|
78
|
+
|
79
|
+
---------- ----------
|
80
|
+
|
81
|
+
1000001 null
|
82
|
+
|
83
|
+
1000002 null
|
84
|
+
|
85
|
+
1000003 null
|
86
|
+
|
87
|
+
1100001 null
|
88
|
+
|
89
|
+
1110000 null
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
SQL>
|
94
|
+
|
95
|
+
```
|