一个特殊的SQL语句

xiaomangxian 2009-03-23 07:44:10
我有一个数据库,里面有几个表,分别是

A表

aid atitle ashow

C表

cid aid ctitle ctime


读取C表前10条数据,并且这十条数据中,aid是不一样的,请问该怎么写呢?
...全文
97 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaomangxian 2009-03-24
  • 打赏
  • 举报
回复
貌似都不行啊
Laura_li 2009-03-23
  • 打赏
  • 举报
回复
select top 10 from c group by aid
或者
select distinct top 10 from c
pt1314917 2009-03-23
  • 打赏
  • 举报
回复
select top 10 * from c a
where not exists(select 1 from c where aid=a.aid and cid<a.cid)
order by cid
wuyq11 2009-03-23
  • 打赏
  • 举报
回复
SELECT * FROM table1 WHERE cid IN (SELECT TOP 10 from table1 GROUP BY aid)
hoojo 2009-03-23
  • 打赏
  • 举报
回复
如果是查A表:

select distinct top 10 cid, aid , ctitle, ctime from a order by aid



试试看吧
^_@
zzxap 2009-03-23
  • 打赏
  • 举报
回复
select top 10 cid, aid , ctitle, ctime from table a where exists (select top 1 aid from table where aid=a.aid )

111,126

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Creator Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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