我有一个如下所示的架构:
CREATE TABLE users
(
id int auto_increment primary key,
name varchar(20),
point int(255)
);
INSERT INTO users
(name, point)
VALUES
('Jack', 1),
('Rick', 5),
('Danny', 11),
('Anthony', 24),
('Barla', 3),
('James', 15),
('Melvin', 12),
('Orthon', 5),
('Kenny', 2),
('Smith', 30),
('Steven', 27),
('Darly', 45),
('Peter', 44),
('Parker', 66),
('Lola', 78),
('Jennifer', 94),
('Smart', 87),
('Jin', 64),
('David', 31),
('Jill', 78),
('Ken', 48),
('Martin', 19),
('Adrian', 20),
('Oliver', 16),
('Ben', 100);
我的 sql 是:
select id, name, point from users Order by point desc, rand() LIMIT 5
问题是,我的查询没有随机选择 5 行并按点排序。任何想法,如何解决它?这里是 sqlfiddle: http ://sqlfiddle.com/#!2/18f15/1