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

2022-08-24 11:42:19

目录mysql设置某字段不能重复mysql查询某个字段不重复的所有记录mysql设置某字段不能重复altertablenovel.novelsortaddunique(name);novel是...

目录
mysql设置某字段不能重复
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 pythona.* from myTapythonble a right join (
select max(id) id from myTable group by ip) b on b.id = a.id
where a.id is not nhttp://www.cppcns.comull

表名为myTable

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

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