回答編集履歴
2
a
answer
CHANGED
@@ -7,5 +7,6 @@
|
|
7
7
|
union all
|
8
8
|
select child.* from t_bbs parent
|
9
9
|
inner join t_bbs child on parent.id = child.parent_id
|
10
|
-
where parent.deleted_at is null
|
10
|
+
where parent.deleted_at is null
|
11
|
+
and child.deleted_at is null;
|
11
12
|
```
|
1
union all, 注釈追記
answer
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
ゴールが分からないですが、欲しい結果はこんな感じでしょうか?
|
2
|
+
インデックスが効かない設計、クエリだと思うので、性能面には気を付けてください。
|
2
3
|
|
3
4
|
```SQL
|
4
5
|
select * from t_bbs
|
5
6
|
where parent_id is null and deleted_at is null
|
6
|
-
union
|
7
|
+
union all
|
7
8
|
select child.* from t_bbs parent
|
8
9
|
inner join t_bbs child on parent.id = child.parent_id
|
9
10
|
where parent.deleted_at is null;
|