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
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%>