当前位置: 代码迷 >> ASP >> 求求:合并sql查询语句,该如何解决
  详细解决方案

求求:合并sql查询语句,该如何解决

热度:310   发布时间:2012-03-27 13:44:24.0
求求:合并sql查询语句
select   top   5   *   from   news   where   newstype=1
select   top   5   *   from   news   where   newstype=2
select   top   5   *   from   news   where   newstype=3
select   top   5   *   from   news   where   newstype=4

这四条语句,怎么用一条sql语句来写!




------解决方案--------------------
select top 5 * from news where newstype=1 union all select top 5 * from news where newstype=2 union all select top 5 * from news where newstype=3 ...........
  相关解决方案