select *,Row_Number() over(order by id)as Row
from
(
select id,title,[content] from t_news where title like '%童丽%'
union
select id,title,[content] from t_news where [content] like '%童丽%'
)t
where Row between 3 and 5
列名 'Row' 无效。是不是因为表t中没有Row列的原因?
该怎么改呢?
from
(
select id,title,[content] from t_news where title like '%童丽%'
union
select id,title,[content] from t_news where [content] like '%童丽%'
)t
where Row between 3 and 5
列名 'Row' 无效。是不是因为表t中没有Row列的原因?
该怎么改呢?
(
select *,Row_Number() over(order by id)as Rowid
from
(
select id,title,[content] from t_news where title like '%童丽%'
union
select id,title,[content] from t_news where [content] like '%童丽%'
) t
) m
where Rowid between 3 and 5
--SQL逻辑执行顺序
(8) SELECT (9) DISTINCT (11) <TOP_specification> <select_list>
(1) FROM <left_table>
(3) <join_type> JOIN <right_table>
(2) ON <join_condition>
(4) WHERE <where_condition>
(5) GROUP BY <group_by_list>
(6) WITH {CUBE | ROLLUP}
(7) HAVING <having_condition>
(10)ORDER BY <order_by_list>
from
(select id,title,[content],Row_Number() over(order by id)as Row
from t_news
where title like '%童丽%' or [content] like '%童丽%'
)t
where Row between 3 and 5