首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

两个表时间字段名不同,union后的order by该怎样写?解决方法

2012-02-03 
两个表时间字段名不同,union后的order by该怎样写?SELECTtitle,timesFROMitem1WHEREtitleLIKE% +Replace(

两个表时间字段名不同,union后的order by该怎样写?
SELECT     title,   times   FROM     item1     WHERE   title   LIKE   '% "   +   Replace(Recordset1__MMColParam,   " ' ",   " ' ' ")   +   "% '         Union   all   (SELECT     title,   addtimes   as   times   FROM   item2     WHERE   title   LIKE   '% "   +   Replace(Recordset1__MMColParam,   " ' ",   " ' ' ")   +   "% '   order   by   ....写times?addtimes?怎么写?

[解决办法]
select * from
(
SELECT title, times FROM item1 WHERE title LIKE '% " + Replace(Recordset1__MMColParam, " ' ", " ' ' ") + "% '
Union all
(SELECT title, addtimes as times FROM item2 WHERE title LIKE '% " + Replace(Recordset1__MMColParam, " ' ", " ' ' ") + "% '
) t
order by times

热点排行
Bad Request.