菜鸟的问题

田老狮 2004-12-29 05:05:03
我有两张表A 和 B ,而且字段也不一样,我要把两个表中的内容都读出来,并且要把B中的内容置

顶,A中的内容根据添加时间自动选前10条,应该怎么做?我做的是一个聊天室,B中放的是一些系统

信息,因为特殊原因必须把这些信息独立出来建一个表

我原来写的是一个存储过程,现在要改,不知道怎么做了

大家帮帮忙~~~~~~~~~~~~~~~~~
...全文
64 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
田老狮 2004-12-29
  • 打赏
  • 举报
回复
Create Procedure Main_Content

@chat_id int,
@User_mob varchar(20)

As

select top 10 * from
(
select T.chatcon_id as chatcon_id,T.chat_id as chat_id,U.User_name+':'as User_name,T.chat_text as chat_text from T_CHATCON as T
left join T_USER as U on T.chat_usermob=U.user_mobile where T.chat_text_pro=0
union all
select T.chatcon_id as chatcon_id,T.chat_id as chat_id,'信息:'as User_name,T.chat_text as chat_text from T_CHATCON as T where T.chat_text_pro=3
union all
select T.chatcon_id as chatcon_id,T.chat_id as chat_id,'你对['+(select user_name from T_user where user_mobile=T.chat_to_usermob)+']说:'as User_name,
T.chat_text as chat_text from T_CHATCON as T left join T_USER as U on T.chat_usermob=U.user_mobile where T.chat_text_pro=1 and T.chat_usermob=@User_mob
union all
select T.chatcon_id as chatcon_id,T.chat_id as chat_id,'['+U.User_name+']对你说:' as User_name,T.chat_text as chat_text from T_CHATCON as T
left join T_USER as U on T.chat_usermob=U.user_mobile where T.chat_text_pro=1 and T.chat_to_usermob=@User_mob)
TBALE_TEMP where chat_id=@chat_id order by chatcon_id desc



GO

这是原来的过程

现在还有一个表 字段是:
news_id,News_conent,news_addtime,news_chatid(所属房间ID)
qfacy 2004-12-29
  • 打赏
  • 举报
回复
select * from b
while rs.eof
<td><%=rs("字段")%></td>
<%rs.movenext
wend%>
select top 10 * from b order by 时间字段 desc
while rs.eof
<td><%=rs("字段")%></td>
<%rs.movenext
wend%>
kelven_vong 2004-12-29
  • 打赏
  • 举报
回复
select两次,先select要固顶的,再select按时间浏览的
mymyal123 2004-12-29
  • 打赏
  • 举报
回复
写具体点好吗?把表结构写出来

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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