質問編集履歴

3

書式改善

2019/12/01 15:25

投稿

spell
spell

スコア16

test CHANGED
File without changes
test CHANGED
@@ -42,7 +42,7 @@
42
42
 
43
43
  HAVING
44
44
 
45
- hoge3_column = 1 OR hoge2_column = 0 AND hoge_status = 1;
45
+ hoge3_column = 1 OR ( hoge2_column = 0 AND hoge_status = 1 );
46
46
 
47
47
  ```
48
48
 

2

HAVING条件表示修正

2019/12/01 15:24

投稿

spell
spell

スコア16

test CHANGED
File without changes
test CHANGED
@@ -42,11 +42,7 @@
42
42
 
43
43
  HAVING
44
44
 
45
- hoge3_column = 1
46
-
47
- OR
48
-
49
- hoge2_column = 0 AND hoge_status = 1;
45
+ hoge3_column = 1 OR hoge2_column = 0 AND hoge_status = 1;
50
46
 
51
47
  ```
52
48
 

1

SQL文修正及びカラム名修正

2019/12/01 15:17

投稿

spell
spell

スコア16

test CHANGED
File without changes
test CHANGED
@@ -8,13 +8,17 @@
8
8
 
9
9
  SELECT
10
10
 
11
- hoge1
11
+ hoge1_column
12
12
 
13
- , hoge2
13
+ , hoge2_column
14
14
 
15
- , hoge3
15
+ , hoge3_column
16
16
 
17
17
  , LEAST( COALESCE( MIN( hoge1_flg ), 99 ), COALESCE( MIN( hoge2_flg ), 99 ), COALESCE( MIN( hoge3_flg ), 99 ) ) AS hoge_status
18
+
19
+ FROM
20
+
21
+ hoge
18
22
 
19
23
  LEFT JOIN
20
24
 
@@ -28,25 +32,21 @@
28
32
 
29
33
  hoge3 ON hoge.fuga = hoge3.fuga
30
34
 
31
- FROM
32
-
33
- hoge
34
-
35
35
  WHERE
36
36
 
37
37
  hoge_flg = 1
38
38
 
39
39
  GROUP BY
40
40
 
41
- hoge1
41
+ hoge1_column
42
42
 
43
43
  HAVING
44
44
 
45
- hoge3 = 1
45
+ hoge3_column = 1
46
46
 
47
47
  OR
48
48
 
49
- hoge2 = 0 AND hoge_status = 1;
49
+ hoge2_column = 0 AND hoge_status = 1;
50
50
 
51
51
  ```
52
52
 
@@ -54,7 +54,7 @@
54
54
 
55
55
  ```Eloquent
56
56
 
57
- self::selectRaw( 'hoge1, hoge2, hoge3' )
57
+ self::selectRaw( 'hoge1_column, hoge2_column, hoge3_column' )
58
58
 
59
59
  ->selectRaw( 'LEAST( COALESCE( MIN( hoge1_flg ), 99 ), COALESCE( MIN( hoge2_flg ), 99 ), COALESCE( MIN( hoge3_flg ), 99 ) ) AS hoge_status' )
60
60
 
@@ -64,7 +64,7 @@
64
64
 
65
65
  ->leftJoin( 'hoge3', 'hoge.fuga', '=', 'hoge2.fuga' )
66
66
 
67
- ->groupBy( 'hoge1' )
67
+ ->groupBy( 'hoge1_column' )
68
68
 
69
69
  ->get();
70
70
 
@@ -74,7 +74,7 @@
74
74
 
75
75
  ```Eloquent
76
76
 
77
- having( 'hoge3', '=', '1' )
77
+ having( 'hoge3_column', '=', '1' )
78
78
 
79
79
  ```
80
80
 
@@ -82,7 +82,7 @@
82
82
 
83
83
  ```Eloquent
84
84
 
85
- where( 'hoge3', '=', '1' )
85
+ where( 'hoge3_column', '=', '1' )
86
86
 
87
87
  ```
88
88
 
@@ -94,7 +94,7 @@
94
94
 
95
95
  ```Eloquent
96
96
 
97
- havingRaw( 'hoge2 = 0 AND hoge_status = 1' )
97
+ havingRaw( 'hoge2_column = 0 AND hoge_status = 1' )
98
98
 
99
99
  ```
100
100