質問編集履歴

4

e

2015/06/04 12:29

投稿

maru--ko
maru--ko

スコア27

test CHANGED
File without changes
test CHANGED
@@ -146,6 +146,10 @@
146
146
 
147
147
  FROM posts
148
148
 
149
+ WHERE group_id = 1
150
+
151
+ ORDER BY created_at DESC;
152
+
149
153
  )
150
154
 
151
155
  UNION ALL
@@ -172,14 +176,10 @@
172
176
 
173
177
  FROM tweets
174
178
 
179
+ WHERE group_id = 1
180
+
181
+ ORDER BY created_at DESC;
182
+
175
183
  )
176
184
 
177
- WHERE
178
-
179
- group_id = 1
180
-
181
- ORDER BY
182
-
183
- created_at DESC;
184
-
185
185
  ```

3

e

2015/06/04 12:29

投稿

maru--ko
maru--ko

スコア27

test CHANGED
File without changes
test CHANGED
@@ -111,3 +111,75 @@
111
111
  --------------------------------------------------------------------------------------------------------------------------
112
112
 
113
113
  ```
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+ ```lang-sql
126
+
127
+ (
128
+
129
+ SELECT
130
+
131
+ group_id,
132
+
133
+ id AS post_id,
134
+
135
+ NULL AS tweet_id,
136
+
137
+ title,
138
+
139
+ description,
140
+
141
+ NULL AS tweet,
142
+
143
+ user_id,
144
+
145
+ created_at
146
+
147
+ FROM posts
148
+
149
+ )
150
+
151
+ UNION ALL
152
+
153
+ (
154
+
155
+ SELECT
156
+
157
+ group_id,
158
+
159
+ NULL AS post_id,
160
+
161
+ id AS tweet_id,
162
+
163
+ NULL AS title,
164
+
165
+ NULL AS description,
166
+
167
+ tweet,
168
+
169
+ user_id,
170
+
171
+ created_at
172
+
173
+ FROM tweets
174
+
175
+ )
176
+
177
+ WHERE
178
+
179
+ group_id = 1
180
+
181
+ ORDER BY
182
+
183
+ created_at DESC;
184
+
185
+ ```

2

修正

2015/06/04 12:25

投稿

maru--ko
maru--ko

スコア27

test CHANGED
File without changes
test CHANGED
File without changes

1

書式の改善

2015/06/04 12:08

投稿

maru--ko
maru--ko

スコア27

test CHANGED
@@ -1 +1 @@
1
- MySQL 別テーブルの重行も含めた複雑な条件取得について
1
+ MySQL 複雑な検索条件のデータ取得について
test CHANGED
File without changes