回答編集履歴

3

調整

2018/11/05 06:27

投稿

yambejp
yambejp

スコア114839

test CHANGED
@@ -19,3 +19,21 @@
19
19
  ```
20
20
 
21
21
  とか?
22
+
23
+
24
+
25
+ # 縦データ
26
+
27
+ 普通に縦データでidと名前を結合したデータがほしいのかな?
28
+
29
+
30
+
31
+ ```SQL
32
+
33
+ create table Post(ID int,name varchar(10));
34
+
35
+ insert into Post values(1,'hoge'),(2,'fuga'),(3,'piyo');
36
+
37
+ select concat(ID,'. ',name) as data from Post order by name asc
38
+
39
+ ```

2

typo

2018/11/05 06:27

投稿

yambejp
yambejp

スコア114839

test CHANGED
@@ -10,9 +10,9 @@
10
10
 
11
11
  select 1 as no ,`1` as data from Post
12
12
 
13
- union all select 2,`1` from Post
13
+ union all select 2,`2` from Post
14
14
 
15
- union all select 3,`1` from Post
15
+ union all select 3,`3` from Post
16
16
 
17
17
  ) as sub order by data asc
18
18
 

1

調整

2018/11/05 06:20

投稿

yambejp
yambejp

スコア114839

test CHANGED
@@ -1,3 +1,21 @@
1
1
  横方向のデータを抽出してソートするのでしょうか?
2
2
 
3
3
  union allしてorder byしてはいけませんか?
4
+
5
+
6
+
7
+ ```SQL
8
+
9
+ select * from(
10
+
11
+ select 1 as no ,`1` as data from Post
12
+
13
+ union all select 2,`1` from Post
14
+
15
+ union all select 3,`1` from Post
16
+
17
+ ) as sub order by data asc
18
+
19
+ ```
20
+
21
+ とか?