select * from news as n where 新闻标题 in (select top 4 新闻标题 from news where typeid=n.typeid)
其实就是查询news表中相同typeid的4条数据!
这个应该是正确的:select * from news as n where 新闻标题 in (select top 4 新闻标题 from news where typeid=n.typeid)
select * from news as n where 新闻标题 in (select top 4 新闻标题 from news where typeid=n.typeid)主要是这个字查询,判断一行的纪录的typeid,选出这个typeid的前四个新闻,然后看主查询中的新闻标题是否在这4个新闻中。
建议用SQL写个函数完成这个工作.
附
(select top 4 新闻标题 from news where typeid=n.typeid)主要是这个字查询,判断一行的纪录的typeid,选出这个typeid的前四个新闻,然后看主查询中的新闻标题是否在这4个新闻中。