SQL语句组合问题,分组查询。
SQL语句组合问题,分组查询。select top 10 id from #C where C=1,
select top 10 id from #C where C=2,
可以组合成一句SQL,但功能不能减,么? 你太强了,没语言说你 select top 10 id from #C where C=1 and C=2
=1 =2的一起查
select top 10 id from #C where C=1 or C=2
这个也一样。。 这样可以都TOP 10了? [quote]原帖由 [i]默飞[/i] 于 2008-6-1 14:21 发表 [url=http://www.im286.com/redirect.php?goto=findpost&pid=26633871&ptid=2627117][img]http://www.im286.com/images/common/back.gif[/img][/url]
SQL语句组合问题,分组查询。
select top 10 id from #C where C=1,
select top 10 id from #C where C=2,
可以组合成一句SQL,但功能不能减,么? [/quote]
select top 10 id from #C where C=1 and c=2 是查不到东西的
select top 10 id from #C where C=1 or c=2 查到的东西又是混起来的
我看还是分开来操作比较合适。 select * from #C where id in(select top 10 id from #C where C=1,select top 10 id from #C where C=2)
这样试试吧,,,我没测试 很简单[code]select top 10 id from #C where C=1
union
select top 10 id from #C where C=2
order by C
[/code] 楼主在学#C 吗
页:
[1]
