请教一个Update语句,功能如下:
Access中的一张表,检查表中F2字段是否有重复的记录,如果有重复的记录,就在该行字段F15中标记出“重复”。
例如:
tb1:
F1 F2 …… F15
1 Yun
2 CCL
3 CCL
4 Yun
5 WQE
运行结果后:
tb1:
F1 F2 …… F15
1 Yun
2 CCL
3 CCL……重复
4 Yun……重复
5 WQE
------解决方案--------------------
- SQL code
--tryupdate a set F15=15 from tb as awhere exists(select 2 from tb where f2=a.f2 and f1<a.f1)
------解决方案--------------------
- SQL code
select F1,F2,case when exists(select 1 from tb b where a.F1=b.F1 then ‘重复' else '' end as F15 from tb a
------解决方案--------------------
update tb1 set f15= cash when exists(select 1 from tb1 where a.f1=b.f1 then '重复'
else '' end
------解决方案--------------------
- SQL code
select F1, F2, case when exists (select 1 from tab b where a.F1=b.F1) then ‘重复' else '' end as F15 from tab a