質問編集履歴

2

追記

2018/04/28 02:00

投稿

randr
randr

スコア202

test CHANGED
File without changes
test CHANGED
@@ -40,13 +40,23 @@
40
40
 
41
41
 
42
42
 
43
+ **users**
44
+
45
+ |userid|username|auth|
46
+
47
+ |:--|:--|--:|
48
+
49
+ |0001|あいうえお|1|
50
+
51
+ |0002|管理者A|3|
52
+
43
53
 
44
54
 
45
55
  理想の結果
46
56
 
47
57
  ------
48
58
 
49
- ```pl/pgsql
59
+ ```SQL
50
60
 
51
61
  create or replace function codes(_kind varchar(10))
52
62
 
@@ -102,6 +112,26 @@
102
112
 
103
113
 
104
114
 
115
+ ```SQL
116
+
117
+ select * from users natural join code('auth');
118
+
119
+ ```
120
+
121
+
122
+
123
+ **上記SQLの結果**
124
+
125
+ |userid|username|auth|code_value|
126
+
127
+ |:--|:----:|:----:|--:|
128
+
129
+ |0001|あいうえお|1|一般|
130
+
131
+ |0002|管理者A|3|管理者|
132
+
133
+
134
+
105
135
  教えてほしいこと/やってみたこと
106
136
 
107
137
  ---

1

誤字脱字

2018/04/28 02:00

投稿

randr
randr

スコア202

test CHANGED
File without changes
test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  **codelist**
6
6
 
7
- |kind|key|value|
7
+ |kind|code_key|code_value|
8
8
 
9
9
  |:--|:--:|--:|
10
10
 
@@ -50,11 +50,11 @@
50
50
 
51
51
  create or replace function codes(_kind varchar(10))
52
52
 
53
- return table(****) as $$
53
+ returns table(****) as $$
54
54
 
55
55
  begin
56
56
 
57
- return query select key, value from codelist where kind = _kind;
57
+ return query select code_key, code_value from codelist where kind = _kind;
58
58
 
59
59
  end;
60
60
 
@@ -64,7 +64,7 @@
64
64
 
65
65
  **codes('status')の結果**
66
66
 
67
- |status|value|
67
+ |status|code_value|
68
68
 
69
69
  |:--|--:|
70
70
 
@@ -90,7 +90,7 @@
90
90
 
91
91
  **上記SQLの結果**
92
92
 
93
- |id|title|status|value|
93
+ |id|title|status|code_value|
94
94
 
95
95
  |:--|:----:|:----:|--:|
96
96