Newbies Goldkim Posted August 11, 2005 Newbies Posted August 11, 2005 Hi, all, I tried count (field) and it always return 1 although I changed several fields. Does any one know how to count the total number of records in a database. It should very easy but I just can not get it. thanks.
SlimJim Posted August 11, 2005 Posted August 11, 2005 Make a second occurrence of your table and relate them by X so all records are related to all records. Call the second table occurrence Counter. Then count(Counter::field) will give you the total number of records. (I'm sure there are other ways of doing it.)
Newbies Goldkim Posted August 12, 2005 Author Newbies Posted August 12, 2005 Hi, Slim Jim It works for me. Thanks a lot.
LaRetta Posted August 12, 2005 Posted August 12, 2005 "how to count the total number of records in a database." Ummm, maybe Get(TotalRecordCount) would do what you wish also? If you use a self-join to count, remember to count a field which always contains something, like a serial or ID. If the field being counted is empty, it won't, ummm, count. :(
SlimJim Posted August 12, 2005 Posted August 12, 2005 I thought there might be other ways of doing it. I keep a cartesian join alongside most of my tables for ID control. So it is natural to use it for table stats, and I do count the ID field (Should have mentioned that, thanks for pointing it out.)
SlimJim Posted August 12, 2005 Posted August 12, 2005 I've tried to respond to this once already so if this is a repeat - apologies. I knew there would be other methods. I keep a cartesian join alongside most of my tables for ID control so it is natural to also use it for full table stats. I do count the record ID and I should have said that. Many thans for pointing it out.
Ender Posted August 12, 2005 Posted August 12, 2005 For large tables, counting through the relationship will end up slowing things down unnecessarily. It's better to use the Get() function in this case.
Recommended Posts
This topic is 7044 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now