网络编程
位置:首页>> 网络编程>> 数据库>> mysql设置某字段不能重复问题

mysql设置某字段不能重复问题

作者:I  发布时间:2024-01-19 19:22:14 

标签:mysql,字段,重复

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

mysql设置某字段不能重复问题

来源:https://blog.csdn.net/rj2017211811/article/details/88755932

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com