回答編集履歴
2
変更
test
CHANGED
@@ -44,7 +44,7 @@
|
|
44
44
|
|
45
45
|
right join テーブルB b using(id)
|
46
46
|
|
47
|
-
) t1 where a_value
|
47
|
+
) t1 where 'ccc' in (a_value,b_value);
|
48
48
|
|
49
49
|
```
|
50
50
|
|
1
追加
test
CHANGED
@@ -19,3 +19,33 @@
|
|
19
19
|
|
20
20
|
|
21
21
|
```
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
> 上記テーブル構成でcccやeeeと検索すると1レコードヒットし、fffと検索すると結果無し
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
も作成してみました。
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
```sql
|
34
|
+
|
35
|
+
select * from (
|
36
|
+
|
37
|
+
select id, a.value a_value, b.value b_value from テーブルA a
|
38
|
+
|
39
|
+
left join テーブルB b using(id)
|
40
|
+
|
41
|
+
union
|
42
|
+
|
43
|
+
select id, a.value, b.value from テーブルA a
|
44
|
+
|
45
|
+
right join テーブルB b using(id)
|
46
|
+
|
47
|
+
) t1 where a_value='ccc' or b_value='ccc';
|
48
|
+
|
49
|
+
```
|
50
|
+
|
51
|
+
|