回答編集履歴

1

追記

2021/07/02 12:24

投稿

shiketa
shiketa

スコア4061

test CHANGED
@@ -29,3 +29,99 @@
29
29
  ;
30
30
 
31
31
  ```
32
+
33
+
34
+
35
+ > しかし
36
+
37
+ > error: syntax error at or near "null"
38
+
39
+ > と言われてしまいました
40
+
41
+
42
+
43
+ とのコメントを受けての追記。
44
+
45
+
46
+
47
+
48
+
49
+ ```sql
50
+
51
+ create table xx (id text, name text, column_A text);
52
+
53
+ create table yy (id text, name text, column_B text);
54
+
55
+
56
+
57
+ insert into xx VALUES
58
+
59
+ ('0501', 'aaa', '0'),
60
+
61
+ ('0502', 'bbb', '1'),
62
+
63
+ ('0503', 'ccc', '0')
64
+
65
+ ;
66
+
67
+
68
+
69
+ insert into yy VALUES
70
+
71
+ ('0661', 'ooo', '0'),
72
+
73
+ ('0662', 'ppp', '1'),
74
+
75
+ ('0663', 'qqq', '1')
76
+
77
+ ;
78
+
79
+ ```
80
+
81
+
82
+
83
+ ```sql
84
+
85
+ with
86
+
87
+ may as (
88
+
89
+ select id, name, column_A, null as column_B from xx
90
+
91
+ ),
92
+
93
+ june as (
94
+
95
+ select id, name, null as column_A, column_B from yy
96
+
97
+ ),
98
+
99
+ hoge as (
100
+
101
+ select * from may union select * from june
102
+
103
+ )
104
+
105
+ select * from hoge where column_A = '1' or column_B = '1'
106
+
107
+ ;
108
+
109
+ ```
110
+
111
+
112
+
113
+ ```
114
+
115
+ id | name | column_a | column_b
116
+
117
+ ------+------+----------+----------
118
+
119
+ 0502 | bbb | 1 |
120
+
121
+ 0662 | ppp | | 1
122
+
123
+ 0663 | qqq | | 1
124
+
125
+ (3 行)
126
+
127
+ ```