回答編集履歴
1
追記
answer
CHANGED
@@ -13,4 +13,52 @@
|
|
13
13
|
)
|
14
14
|
select * from hoge where column_A = '1' or column_B = '1'
|
15
15
|
;
|
16
|
+
```
|
17
|
+
|
18
|
+
> しかし
|
19
|
+
> error: syntax error at or near "null"
|
20
|
+
> と言われてしまいました
|
21
|
+
|
22
|
+
とのコメントを受けての追記。
|
23
|
+
|
24
|
+
|
25
|
+
```sql
|
26
|
+
create table xx (id text, name text, column_A text);
|
27
|
+
create table yy (id text, name text, column_B text);
|
28
|
+
|
29
|
+
insert into xx VALUES
|
30
|
+
('0501', 'aaa', '0'),
|
31
|
+
('0502', 'bbb', '1'),
|
32
|
+
('0503', 'ccc', '0')
|
33
|
+
;
|
34
|
+
|
35
|
+
insert into yy VALUES
|
36
|
+
('0661', 'ooo', '0'),
|
37
|
+
('0662', 'ppp', '1'),
|
38
|
+
('0663', 'qqq', '1')
|
39
|
+
;
|
40
|
+
```
|
41
|
+
|
42
|
+
```sql
|
43
|
+
with
|
44
|
+
may as (
|
45
|
+
select id, name, column_A, null as column_B from xx
|
46
|
+
),
|
47
|
+
june as (
|
48
|
+
select id, name, null as column_A, column_B from yy
|
49
|
+
),
|
50
|
+
hoge as (
|
51
|
+
select * from may union select * from june
|
52
|
+
)
|
53
|
+
select * from hoge where column_A = '1' or column_B = '1'
|
54
|
+
;
|
55
|
+
```
|
56
|
+
|
57
|
+
```
|
58
|
+
id | name | column_a | column_b
|
59
|
+
------+------+----------+----------
|
60
|
+
0502 | bbb | 1 |
|
61
|
+
0662 | ppp | | 1
|
62
|
+
0663 | qqq | | 1
|
63
|
+
(3 行)
|
16
64
|
```
|