sql - Grails Count By does not return correct value -



sql - Grails Count By does not return correct value -

i trying homecoming total count of items in database using grails count query have

def string = "'%"+params.query+"%'" def sqlquery ="select count(status) document status= '"+params.status+"' , doc_name "+string; total = document.executequery(sqlquery);

this should homecoming me total count returning 0 instead of 724 tried

total = document.countbystatusanddocnamelike(params.docstatus,string);

but getting 0 instead of 724

which wierd because returns right value

def sqlquery ="select count(status) document doc_name "+string; total = document.executequery(sqlquery);

so, if these two:

def sqlquery ="select count(status) document status= '"+params.status+"' , doc_name "+string; total = document.executequery(sqlquery);

and

total = document.countbystatusanddocnamelike(params.docstatus,string);

return same thing (and should), count homecoming 0, yet this:

def sqlquery ="select count(status) document doc_name "+string; total = document.executequery(sqlquery);

returns docs expect, must suggest docs expect not have status in params.status . suggest printing out value of params.status is, , see if matches... exactly... values in 724 docs you're expecting back. note count(status) in lastly query isn't counting ones have params.status in (as params.status isn't mentioned in query)... might count(*).

sql hibernate grails count hql

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -