From: khaines@... Date: 2006-12-29T00:18:04+09:00 Subject: Re: Syntax for db count query needed On Thu, 28 Dec 2006, Ruby Quest wrote: > can any one tell me the controller syntax for db record count? > > I want to specify this mysql query syntax in controller > > select count(*) from tablename where user_id=7; > > what is the controller syntax similar to the above sql quert? Sure! I do it like this: count = ksdbh.count(:Tablename) {|r| r.user_id == 7} Other people probably do it differently, though. Details are important when asking a "How do I...?" question. I imagine that you are actually asking how to do that using ActiveRecord, right? If so, while you will probably get a correct answer for AR from someone on this list, the better place to ask those questions is the Rails list. Thanks, Kirk Haines