请教:如何筛选相同的数据。

axinko 2009-11-07 03:59:51
提取相同的表的数据,但是如果二个表(KS_Article ,KS_U_spxx),每个表已经相同数据Author只提取一条数据,但是如果二个表都有相同的Author又有二个Author重复,请问怎样再排除一个(时间降序)。感谢。可能表达不清,抱歉

set rs=server.CreateObject("adodb.recordset")
rs.open "SELECT * FROM KS_Article where KS_Article.ID in(select max(KS_Article.ID) from KS_Article group by KS_Article.Author)and KS_Article.Author in("&Username&") UNION SELECT * FROM KS_U_spxx where KS_U_spxx.ID in(select max(KS_U_spxx.ID) from KS_U_spxx group by KS_U_spxx.Author)and KS_U_spxx.Author in("&Username&") order by adddate desc",conn,1,1


显示数据
广东省中国青年旅行社 刚发布:[散拼产品]45454 10000 2009-10-20 23:00:37 --这是KS_Article 表的
广东省中国青年旅行社 刚发布:[国内旅游]45454 10000 2009-10-14 16:56:35 --这是KS_U_spxx 表的


但是我只有一个其中一个数据,请问如何查询??谢谢
...全文
73 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ACMAIN_CHM 2009-11-12
  • 打赏
  • 举报
回复
ACMAIN_CHM 2009-11-12
  • 打赏
  • 举报
回复
SELECT * FROM KS_Article a
where Author in("&Username&")
and not exists (select 1 from KS_Article where Author=a.Author and id>a.id)
and not exists (select 1 from KS_U_spxx where Author=a.Author and id>a.id)
union all
SELECT * FROM KS_U_spxx b
where Author in("&Username&")
and not exists (select 1 from KS_Article where Author=b.Author and id>b.id)
and not exists (select 1 from KS_U_spxx where Author=b.Author and id>b.id)

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧