表相关操作
drop table if exists base_user; CREATE TABLE `base_user` ( `id` char(32) NOT NULL DEFAULT '' COMMENT '用户编号', `user_name` varchar(20) NOT NULL DEFAULT '' COMMENT '姓名', `phone_id` char(11) NOT NULL DEFAULT '' COMMENT '手机号' PRIMARY KEY (`id`), UNIQUE KEY `uk_phone_id` (`phone_id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户信息表';
排序
中文排序
order by convert(user_name using gbk) asc
null排序在最后面
order by userName IS NULL, convert(userName using gbk) asc
按照指定顺序排序
ORDER BY FIELD(`id`, 5, 3, 7, 1)