首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

求救于SqlServer高手.解决办法

2012-01-26 
求救于SqlServer高手.我有一张表,表中有个字段:id(int)和另外一个字段:i_text(text)表中内容如下:idi_text

求救于SqlServer高手.
我有一张表,表中有个字段:id(int)和另外一个字段:i_text(text)  

表中内容如下:  

id   i_text  

1   a  
1   b  
1   c  
2   e  
2   f  
2   g  

我需要的sql语句如下:  
读取id=1和id=2的所有的前两条记录.


[解决办法]
select top 2 * from yourtable where id = 1
union
select top 2 * from yourtable where id = 2
[解决办法]
select top 2 * from table1 as t1 where id=1 union select top 2 * from table1 as t2 where id=2

热点排行