回答編集履歴

4

訂正

2021/06/10 08:45

投稿

sazi
sazi

スコア25327

test CHANGED
@@ -44,7 +44,7 @@
44
44
 
45
45
  from area_area
46
46
 
47
- where area_id in (
47
+ where id in (
48
48
 
49
49
  select area_id from area_city
50
50
 

3

推敲

2021/06/10 08:45

投稿

sazi
sazi

スコア25327

test CHANGED
@@ -42,7 +42,7 @@
42
42
 
43
43
  select *
44
44
 
45
- from area_area area
45
+ from area_area
46
46
 
47
47
  where area_id in (
48
48
 

2

推敲

2021/06/10 03:32

投稿

sazi
sazi

スコア25327

test CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
  ```SQL
22
22
 
23
- select *
23
+ select area.*
24
24
 
25
25
  from area_area area
26
26
 

1

追記

2021/06/10 03:31

投稿

sazi
sazi

スコア25327

test CHANGED
@@ -15,3 +15,43 @@
15
15
  )
16
16
 
17
17
  ```
18
+
19
+ 以下の様な記述でも同様な結果になります。
20
+
21
+ ```SQL
22
+
23
+ select *
24
+
25
+ from area_area area
26
+
27
+ inner join (
28
+
29
+ select area_id from area_city
30
+
31
+ where popularity=1
32
+
33
+ group by area_id
34
+
35
+ ) city
36
+
37
+ on area.id=city.area_id
38
+
39
+ ```
40
+
41
+ ```SQL
42
+
43
+ select *
44
+
45
+ from area_area area
46
+
47
+ where area_id in (
48
+
49
+ select area_id from area_city
50
+
51
+ where popularity=1
52
+
53
+ )
54
+
55
+ ```
56
+
57
+ 実行計画を確認して、効率の良い記述を選ぶと良いでしょう。