两张表合并在一起显示如何写?

ekinchen3 2013-07-08 11:16:56
两个表:PicNews图片新闻,Article工作快讯
由于图片新闻更新频繁,工作快讯不怎么更新,想在工作快讯中除了显示工作快讯还要显示图片新闻的标题,按更新日期排序。
原始SQL为:1、select top 5 * from PicNews order by UpdateTime desc
2、select top 11 * from Article where SmallClassName='工作快讯' and IsSelected=1 order by UpdateTime desc
如何合并?
合并后asp链接语句怎么写?以前分别是href=“html/PicNewsOpen.asp?ArticleId=”和href=“html/xxzxopen.asp?ArticleId=”
...全文
167 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
Andy__Huang 2013-07-08
  • 打赏
  • 举报
回复
用union all或union select top 5 * from PicNews order by UpdateTime desc union all select top 11 * from Article where SmallClassName='工作快讯' and IsSelected=1 order by UpdateTime desc 前提是两个表字段结构要一致
lzw_0736 2013-07-08
  • 打赏
  • 举报
回复
字段不一致用默認值填充
ekinchen3 2013-07-08
  • 打赏
  • 举报
回复
引用 1 楼 hdhai9451 的回复:
用union all或union select top 5 * from PicNews order by UpdateTime desc union all select top 11 * from Article where SmallClassName='工作快讯' and IsSelected=1 order by UpdateTime desc 前提是两个表字段结构要一致
就是字段不一致啊!

27,579

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 应用实例
社区管理员
  • 应用实例社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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