mysql设置某字段不能重复

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

mysql设置某字段不能重复

I like study.   2022-09-29 我要评论

mysql设置某字段不能重复

alter table novel.novelsort add unique(name);

novel是数据库 novelsort是表名 name是字段名

mysql查询某个字段不重复的所有记录

select a.id,a.ip,a.creationTime from myTable a right join (
select max(id) id from myTable group by ip) b on b.id = a.id
where a.id is not null

或者

select a.* from myTable a right join (
select max(id) id from myTable group by ip) b on b.id = a.id
where a.id is not null

表名为myTable

以上为个人经验,希望能给大家一个参考,也希望大家多多支持。

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们