27,580
社区成员
发帖
与我相关
我的任务
分享
insert into 目标表
select distinct name,getdate() from user -- 处了name 可以把表中的所有字段都写上 o(∩_∩)o...
--但不要 写 *
如果你不喜欢distinct 也可以使用not exists
insert into 目标表
select name,getdate() from user
where not exists (select 1 from user a a.name=name and a.id<id)
select distinct [name] , getdate() as dt from tb