请教一句SQL语句



数据库access,控件adoquery

内有表 tmp
TMP中有若干除ID外其他字段值相同的一堆记录

tmp字段如下:

id(key),name,level,kind,location,以下的问题只牵涉到 name 字段

记录举例如下:
------------------------------
id name level kind location
1 大坏蛋 1 长期 上海
2 小坏蛋 1 长期 北京
3 小坏蛋 3 短期 北京
4 大坏蛋 1 长期 上海
5 老坏蛋 5 长期 天津
------------------------------
以上可以看出第四条和第一条重复

我先distinct,把TMP中重复的记录剔除,把剩下的into到表 newmsg 中

现在,
newmsg中的内容为

------------------------------
id name level kind location
1 大坏蛋 1 长期 上海
2 小坏蛋 1 长期 北京
3 小坏蛋 3 短期 北京
4 老坏蛋 5 长期 天津
------------------------------

然后我把tmp 用 delete * 清空

现在请注意,newmsg中 大坏蛋有1个,小坏蛋有2个,老坏蛋有1个

现在我想把 newmsg 中 name 的值只有唯一一个的记录放到 tmp 中
也就是说,我希望tmp中的内容是这样的

------------------------------
id name level kind location
1 大坏蛋 1 长期 上海
2 老坏蛋 5 长期 天津
------------------------------

这句 sql 怎么写,我试了几句,统统报错

薄分相酬,不成敬意
[1055 byte] By [kmask-降龙十八顶] at [2007-12-11]
# 1
try this:

insert into tmp select * from newmsg where name in (select name from newmsg group by name having count(*) = 1)
chechy-www.qdocuments.net at 2007-10-21 > top of Msdn China Tech,Delphi,VCL组件开发及应用...
# 2
你的ID好像是IDENITTY类型的,所以,最好用column name代替*。
chechy-www.qdocuments.net at 2007-10-21 > top of Msdn China Tech,Delphi,VCL组件开发及应用...
# 3
insert into tmp
select * from newmsg where name not in
(select name from newmsg group by name having count(*)>1 )
suny_2001-小鱼儿 at 2007-10-21 > top of Msdn China Tech,Delphi,VCL组件开发及应用...
# 4
哎呀,不好意思,前面有人写了,没看见
suny_2001-小鱼儿 at 2007-10-21 > top of Msdn China Tech,Delphi,VCL组件开发及应用...
# 5
哎呀 ,不好意思。前面有人写过了,比我快
suny_2001-小鱼儿 at 2007-10-21 > top of Msdn China Tech,Delphi,VCL组件开发及应用...
# 6
同意楼上
yuefengzzh-悦风 at 2007-10-21 > top of Msdn China Tech,Delphi,VCL组件开发及应用...