{"action":"opened","issue":{"url":"https://api.github.com/repos/lovecn/lovecn.github.io/issues/28","labels_url":"https://api.github.com/repos/lovecn/lovecn.github.io/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/lovecn/lovecn.github.io/issues/28/comments","events_url":"https://api.github.com/repos/lovecn/lovecn.github.io/issues/28/events","html_url":"https://github.com/lovecn/lovecn.github.io/issues/28","id":83497746,"number":28,"title":"MySQL记录","user":{"login":"lovecn","id":6429263,"avatar_url":"https://avatars.githubusercontent.com/u/6429263?v=3","gravatar_id":"","url":"https://api.github.com/users/lovecn","html_url":"https://github.com/lovecn","followers_url":"https://api.github.com/users/lovecn/followers","following_url":"https://api.github.com/users/lovecn/following{/other_user}","gists_url":"https://api.github.com/users/lovecn/gists{/gist_id}","starred_url":"https://api.github.com/users/lovecn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lovecn/subscriptions","organizations_url":"https://api.github.com/users/lovecn/orgs","repos_url":"https://api.github.com/users/lovecn/repos","events_url":"https://api.github.com/users/lovecn/events{/privacy}","received_events_url":"https://api.github.com/users/lovecn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-06-01T13:32:13Z","updated_at":"2015-06-01T13:32:13Z","closed_at":null,"body":"```php\r\n\r\nmysql> select *from history;\r\n+----+---------------------+-----+-----+\r\n| id | time                | uid | num |\r\n+----+---------------------+-----+-----+\r\n|  1 | 2015-05-01 11:11:11 |   1 |   1 |\r\n|  2 | 2015-05-02 11:11:11 |   1 |   2 |\r\n|  3 | 2015-05-03 11:11:11 |   1 |   3 |\r\n|  4 | 2015-05-01 11:11:11 |   2 |   1 |\r\n|  5 | 2015-05-02 11:11:11 |   2 |   2 |\r\n|  6 | 2015-05-03 11:11:11 |   2 |   3 |\r\n+----+---------------------+-----+-----+\r\n//uid的历史记录中时间最大的记录\r\nmysql> select a.*from (select *from history where uid in(1,2)) a inner join (select max(time) max_time ,uid from history where uid in (1,2) group by uid) b where a.uid=b.uid and a.time =b.max_time;\r\n+----+---------------------+-----+-----+\r\n| id | time                | uid | num |\r\n+----+---------------------+-----+-----+\r\n|  3 | 2015-05-03 11:11:11 |   1 |   3 |\r\n|  6 | 2015-05-03 11:11:11 |   2 |   3 |\r\n+----+---------------------+-----+-----+\r\n2 rows in set (0.00 sec)\r\n\r\n```"}}