回答編集履歴
2
変更
answer
CHANGED
@@ -21,5 +21,5 @@
|
|
21
21
|
union
|
22
22
|
select id, a.value, b.value from テーブルA a
|
23
23
|
right join テーブルB b using(id)
|
24
|
-
) t1 where
|
24
|
+
) t1 where 'ccc' in (a_value,b_value);
|
25
25
|
```
|
1
追加
answer
CHANGED
@@ -8,4 +8,18 @@
|
|
8
8
|
right join テーブルB b using(id)
|
9
9
|
order by 1;
|
10
10
|
|
11
|
-
```
|
11
|
+
```
|
12
|
+
|
13
|
+
> 上記テーブル構成でcccやeeeと検索すると1レコードヒットし、fffと検索すると結果無し
|
14
|
+
|
15
|
+
も作成してみました。
|
16
|
+
|
17
|
+
```sql
|
18
|
+
select * from (
|
19
|
+
select id, a.value a_value, b.value b_value from テーブルA a
|
20
|
+
left join テーブルB b using(id)
|
21
|
+
union
|
22
|
+
select id, a.value, b.value from テーブルA a
|
23
|
+
right join テーブルB b using(id)
|
24
|
+
) t1 where a_value='ccc' or b_value='ccc';
|
25
|
+
```
|