读书人

两个表时间字段名不同union后的orde

发布时间: 2012-02-03 22:02:47 作者: rapoo

两个表时间字段名不同,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

读书人网 >SQL Server

热点推荐