回答編集履歴
5
調整
test
CHANGED
@@ -20,13 +20,17 @@
|
|
20
20
|
```
|
21
21
|
|
22
22
|
# 範囲指定あり
|
23
|
+
バージョンの違いを吸収
|
23
24
|
```SQL
|
24
|
-
update logs as t1
|
25
|
+
update logs as t1, logs as t2
|
25
|
-
set created=date_format(created,'%Y-%m-%d 23:59:59') + interval
|
26
|
+
set t1.created=date_format(t2.created,'%Y-%m-%d 23:59:59') + interval
|
26
|
-
coalesce((select 1 from logs where page_no=t
|
27
|
+
coalesce((select 1 from (select * from logs) as t3 where page_no=t2.page_no and id<t2.id),0) second
|
27
|
-
,day=date_format(created+ interval
|
28
|
+
,t1.day=date_format(t2.created+ interval
|
28
|
-
coalesce((select 1 from logs where page_no=t
|
29
|
+
coalesce((select 1 from (select * from logs) as t3 where page_no=t2.page_no and id<t2.id),0) day,'%d')
|
29
|
-
,hour=coalesce((select '00' from logs where page_no=t
|
30
|
+
,t1.hour=coalesce((select '00' from (select * from logs) as t3 where page_no=t2.page_no and id<t2.id),'23')
|
31
|
+
where
|
32
|
+
t1.id=t2.id
|
30
|
-
|
33
|
+
and t1.contents_no = '22011'
|
31
|
-
|
34
|
+
and t1.created BETWEEN '2022-09-20 13:00:00' AND '2022-09-20 13:59:59'
|
35
|
+
|
32
36
|
```
|
4
条件
test
CHANGED
@@ -18,3 +18,15 @@
|
|
18
18
|
,hour=coalesce((select '00' from logs where page_no=t1.page_no and id<t1.id),'23')
|
19
19
|
|
20
20
|
```
|
21
|
+
|
22
|
+
# 範囲指定あり
|
23
|
+
```SQL
|
24
|
+
update logs as t1
|
25
|
+
set created=date_format(created,'%Y-%m-%d 23:59:59') + interval
|
26
|
+
coalesce((select 1 from logs where page_no=t1.page_no and id<t1.id),0) second
|
27
|
+
,day=date_format(created+ interval
|
28
|
+
coalesce((select 1 from logs where page_no=t1.page_no and id<t1.id),0) day,'%d')
|
29
|
+
,hour=coalesce((select '00' from logs where page_no=t1.page_no and id<t1.id),'23')
|
30
|
+
where contents_no = '22011'
|
31
|
+
AND created BETWEEN '2022-09-20 13:00:00' AND '2022-09-20 13:59:59'
|
32
|
+
```
|
3
chousei
test
CHANGED
@@ -7,9 +7,14 @@
|
|
7
7
|
set created=date_format(created,'%Y-%m-%d 00:00:00')+interval 1 day
|
8
8
|
where not exists(select 1 from logs where page_no=t1.page_no and id>t1.id);
|
9
9
|
```
|
10
|
-
一発でやるならこんな感じ?
|
10
|
+
一発でやるならこんな感じ?
|
11
|
+
dayとhourも修正対象だったので調整
|
11
12
|
```SQL
|
12
13
|
update logs as t1
|
13
14
|
set created=date_format(created,'%Y-%m-%d 23:59:59') + interval
|
14
15
|
coalesce((select 1 from logs where page_no=t1.page_no and id<t1.id),0) second
|
16
|
+
,day=date_format(created+ interval
|
17
|
+
coalesce((select 1 from logs where page_no=t1.page_no and id<t1.id),0) day,'%d')
|
18
|
+
,hour=coalesce((select '00' from logs where page_no=t1.page_no and id<t1.id),'23')
|
19
|
+
|
15
20
|
```
|
2
chousei
test
CHANGED
@@ -7,9 +7,9 @@
|
|
7
7
|
set created=date_format(created,'%Y-%m-%d 00:00:00')+interval 1 day
|
8
8
|
where not exists(select 1 from logs where page_no=t1.page_no and id>t1.id);
|
9
9
|
```
|
10
|
-
一発でやるならこんな感じ?
|
10
|
+
一発でやるならこんな感じ?(微調整)
|
11
11
|
```SQL
|
12
12
|
update logs as t1
|
13
|
-
set created=date_format(created,'%Y-%m-%d
|
13
|
+
set created=date_format(created,'%Y-%m-%d 23:59:59') + interval
|
14
|
-
coalesce((select 1 from logs where page_no=t1.page_no and id
|
14
|
+
coalesce((select 1 from logs where page_no=t1.page_no and id<t1.id),0) second
|
15
15
|
```
|
1
chousei
test
CHANGED
@@ -7,3 +7,9 @@
|
|
7
7
|
set created=date_format(created,'%Y-%m-%d 00:00:00')+interval 1 day
|
8
8
|
where not exists(select 1 from logs where page_no=t1.page_no and id>t1.id);
|
9
9
|
```
|
10
|
+
一発でやるならこんな感じ?
|
11
|
+
```SQL
|
12
|
+
update logs as t1
|
13
|
+
set created=date_format(created,'%Y-%m-%d 00:00:00')+interval 1 day - interval
|
14
|
+
coalesce((select 1 from logs where page_no=t1.page_no and id>t1.id),0) second
|
15
|
+
```
|