select count(*) from tablename where 条件 知道所有符合条件的条数。 select * from tablename where rownum <10 and 条件 取前10条记录。
我是对这三个表做联合查询如下: select id,name from t1 where name like '%sky%' union select id,name from t2 where name like '%sky%' union id,name from where name like '%sky%' 这时我如何用rownum呢?不知道是不是可行?
可以,如果要按照某字段排序,则 select * from (select id,name from t1 where name like '%sky%' union select id,name from t2 where name like '%sky%' union id,name from where name like '%sky%' order by id desc) where rownum<11;
知道所有符合条件的条数。
select * from tablename where rownum <10 and 条件
取前10条记录。
select id,name from t1 where name like '%sky%' union select id,name from t2 where name like '%sky%' union id,name from where name like '%sky%'
这时我如何用rownum呢?不知道是不是可行?
select * from (select id,name from t1 where name like '%sky%' union select id,name from t2 where name like '%sky%' union id,name from where name like '%sky%' order by id desc) where rownum<11;
再请问一下,有没有办法知道所有符合的记录数呢?
我是说不受rownum限制的结果