ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Schrader <tschra...@gmail.com>
Subject Re: Select count(*) in a resultMap
Date Fri, 27 Jan 2006 21:10:49 GMT
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 existingCount,
                          (SELECT     COUNT(*)
                            FROM          scrimbot_pending_channels spc
                            WHERE      sc.channel = c.channel) AS pendingCount
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