推测出建表语句
create table user1(user_name varchar(20),over varchar(20));
create table user2(user_name varchar(20),over varchar(20)
);
insert user1 values('孙悟空','斗战圣佛');
insert user1 values('猪八戒','净坛使者');
insert user1 values('沙僧','金身罗汉');
insert user1 values('唐僧','旃檀功德佛');
insert user2 values('孙悟空','活佛');
create table user1(user_name varchar(20),over varchar(20));
create table user2(user_name varchar(20),over varchar(20)
);
insert user1 values('孙悟空','斗战圣佛');
insert user1 values('猪八戒','净坛使者');
insert user1 values('沙僧','金身罗汉');
insert user1 values('唐僧','旃檀功德佛');
insert user2 values('孙悟空','活佛');
2017-03-21
优化就别用max,这函数效率不行
SELECT
a.use_name,
b.kills,
b.killtime
FROM im_user AS a
INNER JOIN im_kill AS b ON a.id = b.user_id
WHERE b.kills =
(SELECT
kills
FROM im_kill AS c
WHERE c.user_id=b.user_id
ORDER BY kills DESC
LIMIT 1);
SELECT
a.use_name,
b.kills,
b.killtime
FROM im_user AS a
INNER JOIN im_kill AS b ON a.id = b.user_id
WHERE b.kills =
(SELECT
kills
FROM im_kill AS c
WHERE c.user_id=b.user_id
ORDER BY kills DESC
LIMIT 1);
2017-03-19