回答編集履歴
4
訂正
answer
CHANGED
@@ -21,7 +21,7 @@
|
|
21
21
|
```SQL
|
22
22
|
select *
|
23
23
|
from area_area
|
24
|
-
where
|
24
|
+
where id in (
|
25
25
|
select area_id from area_city
|
26
26
|
where popularity=1
|
27
27
|
)
|
3
推敲
answer
CHANGED
@@ -20,7 +20,7 @@
|
|
20
20
|
```
|
21
21
|
```SQL
|
22
22
|
select *
|
23
|
-
from area_area
|
23
|
+
from area_area
|
24
24
|
where area_id in (
|
25
25
|
select area_id from area_city
|
26
26
|
where popularity=1
|
2
推敲
answer
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
```
|
10
10
|
以下の様な記述でも同様な結果になります。
|
11
11
|
```SQL
|
12
|
-
select *
|
12
|
+
select area.*
|
13
13
|
from area_area area
|
14
14
|
inner join (
|
15
15
|
select area_id from area_city
|
1
追記
answer
CHANGED
@@ -6,4 +6,24 @@
|
|
6
6
|
where exists(
|
7
7
|
select 1 from area_city where area_id=area.id and popularity=1
|
8
8
|
)
|
9
|
-
```
|
9
|
+
```
|
10
|
+
以下の様な記述でも同様な結果になります。
|
11
|
+
```SQL
|
12
|
+
select *
|
13
|
+
from area_area area
|
14
|
+
inner join (
|
15
|
+
select area_id from area_city
|
16
|
+
where popularity=1
|
17
|
+
group by area_id
|
18
|
+
) city
|
19
|
+
on area.id=city.area_id
|
20
|
+
```
|
21
|
+
```SQL
|
22
|
+
select *
|
23
|
+
from area_area area
|
24
|
+
where area_id in (
|
25
|
+
select area_id from area_city
|
26
|
+
where popularity=1
|
27
|
+
)
|
28
|
+
```
|
29
|
+
実行計画を確認して、効率の良い記述を選ぶと良いでしょう。
|