用以下语句只当soft_name,jianjie2,url 3个字段里的内容都跟另一行一样时才能过滤掉
select distinct soft_name,jianjie2,url from softinfo where smalltype=@typeID
比如: ID soft_name jianjie2 url TYPEID
1 QQ软件 聊天 http://abc.com 203
2 QQ软件 聊天 http://abc.com 203
3 QQ软件 聊天软件 http://abcdef.com 203
我只想让他输出1条记录来,如何办?
用select distinct soft_name,jianjie2,url from softinfo where smalltype=@typeID
会输出1,3两条出来!
要怎么半啊,数据库中有几十万的记录,有很多是重复的,要如何过滤?
当然不能用select distinct soft_name from softinfo因为jianjie3字段也要一起查出来
select distinct soft_name,jianjie2,url from softinfo where smalltype=@typeID
比如: ID soft_name jianjie2 url TYPEID
1 QQ软件 聊天 http://abc.com 203
2 QQ软件 聊天 http://abc.com 203
3 QQ软件 聊天软件 http://abcdef.com 203
我只想让他输出1条记录来,如何办?
用select distinct soft_name,jianjie2,url from softinfo where smalltype=@typeID
会输出1,3两条出来!
要怎么半啊,数据库中有几十万的记录,有很多是重复的,要如何过滤?
当然不能用select distinct soft_name from softinfo因为jianjie3字段也要一起查出来
from softinfo t
where not exists(select 1
from softinfo
where soft_name=t.soft_name
and ID<t.ID)
from softinfo t
where smalltype=@typeID
and
not exists(select 1
from softinfo
where soft_name=t.soft_name
and ID<t.ID)
select distinct soft_name,jianjie2,url from softinfo
where ID in
(
select min(id) from softinfo where TYPEID=@typeID group by TYPEID
)
select max(ID) from softinfo group by soft_name)