ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Laccetti" <mich...@s2g-limited.com>
Subject RE: Select count(*) in a resultMap
Date Sat, 28 Jan 2006 05:15:14 GMT
Thanks Ted, I switched it over to select ... from dual, and it worked quite
nicely.  I shall have to remember this for the future.


-----Original Message-----
From: Ted Schrader [mailto:tschrader@gmail.com] 
Sent: January 27, 2006 4:11 PM
To: user-java@ibatis.apache.org
Subject: Re: Select count(*) in a resultMap

Hi Michael,

You've got two options that I can think of off the top of my head.

A.  You execute each query separately, then cobble the results
together "manually" in your Java code to build an instance of

B.  You craft a single query, assuming you have a master table for the
channels (called Channels in this example):

SELECT     channel,
                          (SELECT     COUNT(*)
                            FROM          scrimbot_channels sc
                            WHERE      sc.channel = c.channel) AS
                          (SELECT     COUNT(*)
                            FROM          scrimbot_pending_channels spc
                            WHERE      sc.channel = c.channel) AS
FROM         Channels c

You could use the query above for a queryForList(), or add a suitable
WHERE clause for queryForObject().

If you don't have a "Channels" table, try changing the above query to
hit the "dummy" table, which depends on your particular DBMS.


View raw message