SQL 基础语句
根据排序顺序给sort字段赋值
SET @sort:=0;
UPDATE test,
(
SELECT id, (@sort:=@sort + 1) sort, score FROM test
ORDER BY score DESC
) tmp
SET test.sort_id=tmp.sort
WHERE test.id=tmp.id
创建与已有表结构相同的新表
CREATE TABLE disability_check_1 LIKE disability_check
根据id指定顺序排序
使用FIELD
关键字,根据id根据指定顺序排序
SELECT * FROM user
WHERE FIND_IN_SET(id, 3, 10, 6)
ORDER BY FIELD(id