Row Count

552 views
Skip to first unread message

Moksh Khurana

unread,
Apr 11, 2013, 1:10:20 PM4/11/13
to fm...@googlegroups.com
How do I get the row count of the records fetched after doing a select?

I looked online and there's a method called intForQuery which takes NSString* as an sql statement, but I have that statement + argument array that I want to pass in. How can I do that? Or is there another way? Currently I have executed the selected statement and it is returned in FMResultSet...can I retrieve it from there somehow? 

August Mueller

unread,
Apr 11, 2013, 1:13:31 PM4/11/13
to fm...@googlegroups.com
On Apr 11, 2013, at 10:10 AM, Moksh Khurana <moksh....@gmail.com> wrote:
How do I get the row count of the records fetched after doing a select?

There's no way to do this without looping through the results (unless someone knows of some fancy way to do this that I'm not aware of?)

I looked online and there's a method called intForQuery which takes NSString* as an sql statement, but I have that statement + argument array that I want to pass in. How can I do that? Or is there another way? Currently I have executed the selected statement and it is returned in FMResultSet...can I retrieve it from there somehow? 

Nope.  The intForQuery is just a shorthand way of getting a single result back from a query.

-gus

Scott Andrew

unread,
Apr 11, 2013, 1:20:21 PM4/11/13
to fm...@googlegroups.com
You could always just run the proper SQL statement. I do something like:

FMResultSet *rs = [database executeQuery:@"select count(*) as count from words"];
[rs next];


wordsThatExist = [rs intForColumn:@"count"];


Setting up the SQL query may be quicker and cheaper then iterating.. I believe counts are cheap. 

Scott

--
You received this message because you are subscribed to the Google Groups "FMDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fmdb+uns...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages