合并两个表的两个记录集到一个记录集,sql怎样写

bighai 2004-12-29 03:24:56
sql1:
select c_title from t_news where c_ishot=1 order by c_date desc
sql2:
select c_title from t_affiche where c_ishot=1 order by c_date desc

现在我想把它这两个语句合并起来,并按时间(c_date)排序,有劳各位老大?
...全文
158 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
vitas 2004-12-29
  • 打赏
  • 举报
回复
/////////学艺不精就别出来害后辈/////////
select c_title from t_news where c_ishot=1
union all
select c_title from t_affiche where c_ishot=1
order by c_date desc
vitas 2004-12-29
  • 打赏
  • 举报
回复
注意加上换行符。
RainYang 2004-12-29
  • 打赏
  • 举报
回复
asp是可以执行的,你查查有没有地方写错
bighai 2004-12-29
  • 打赏
  • 举报
回复
不过,按照邹建大哥的语句,在数据库的查询分析器里面可以查询,但为什么不能用在asp语句里面,奇怪!我想一定有人会解决的!
bighai 2004-12-29
  • 打赏
  • 举报
回复
<%
sqltext5=" select c_title from(
select c_title,c_date from t_news where c_ishot=1
union all
select c_title,c_date from t_affiche where c_ishot=1
)a order by c_date desc "

set rs3=server.createobject("adodb.recordset")
rs3.open sqltext5,conn,1,1
%>

多谢几位大哥,按照你们的意民,我写一个asp查询语句,为什么系统提示:

Microsoft VBScript 编译器错误 错误 '800a0409'

未结束的字符串常量

/index2.asp,行311

sqltext5=" select c_title from(
-------------------------------^

不知道是哪里的原因?
yingqing 2004-12-29
  • 打赏
  • 举报
回复
select c_title from(
select c_title,c_date from t_news where c_ishot=1
union all
select c_title,c_date from t_affiche where c_ishot=1
)a order by c_date desc
zjcxc 2004-12-29
  • 打赏
  • 举报
回复
select c_title from(
select c_title,c_date from t_news where c_ishot=1
union all
select c_title,c_date from t_affiche where c_ishot=1
)a order by c_date desc
子陌红尘 2004-12-29
  • 打赏
  • 举报
回复
select c_title from t_news where c_ishot=1
union all
select c_title from t_affiche where c_ishot=1
order by c_date desc
bighai 2004-12-29
  • 打赏
  • 举报
回复
补充一点,只需要查c_title就可以了

27,580

社区成员

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

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