回答編集履歴

1

sample

2016/11/28 03:16

投稿

yambejp
yambejp

スコア117744

test CHANGED
@@ -1,3 +1,21 @@
1
1
  複数条件をlimitで処理しているならorder byしているはずですから
2
2
 
3
3
  おなじorder byをかけてlimit 1でデータをとればよいのでは?
4
+
5
+
6
+
7
+ # sample
8
+
9
+ timestampで管理
10
+
11
+ ```SQL
12
+
13
+ create table tbl(id int not null primary key,val int ,ts timestamp);
14
+
15
+ insert into tbl(id,val) values(1,100),(2,150),(3,300);
16
+
17
+ update tbl set val=400 where id=2;
18
+
19
+ select * from tbl order by ts desc limit 1;
20
+
21
+ ```