Tags: cursor, database, individuallyquery, mysql, number, oracle, query, record, records, return, select, sql, step, variable
How to return the record count of a query to a number variable
How would I get the record count from a query without using a cursor to step through the query and count the records individually?
query: select * from table1 where column1 = column2
How would I get the record count of the query above?
Leave a comment...
- 3 Comments
- I figured it out
select count(*) into theCount
from ( select * from table1 where column1=column2 );
michelle#1; Fri, 22 Feb 2008 11:25:00 GMT
- Or you could just do:
where column1=column2#2; Fri, 22 Feb 2008 11:26:00 GMT
- Or may be like this:
SQL> select (select count(*) from <tablename>
where col1 = col2 ) into counter from Dual;#3; Fri, 22 Feb 2008 11:27:00 GMT