How to do a count(*) in java

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to do a count(*) in java

Yousuf Shakeel
hi everyone,

just started with mybatis,
and I am sort of stuck with doing a count(*) of rows, and returning it, using java, mybatis 3. it returns 0, here is the code i am using.

<select id="getLenBtSessions" parameterType="beans.WeeklyDataBean"
        resultType="int">
        select count(*) 
        from eow_data
        where
        stock_symbol=#{symbol}
         and session_no_start &gt; #{sessionStart}
         and session_no_end &lt; #{sessionEnd}
</select>
Reply | Threaded
Open this post in threaded view
|

Re: How to do a count(*) in java

Jackie Li
Hi,

You need to define the returned column name.

select count(*) <column_name> from .....

Cheers,
Jackie


On Mon, Mar 28, 2011 at 00:08, Yousuf Shakeel <[hidden email]> wrote:
hi everyone,

just started with mybatis,
and I am sort of stuck with doing a count(*) of rows, and returning it, using java, mybatis 3. it returns 0, here is the code i am using.

<select id="getLenBtSessions" parameterType="beans.WeeklyDataBean"
        resultType="int">
        select count(*) 
        from eow_data
        where
        stock_symbol=#{symbol}
         and session_no_start &gt; #{sessionStart}
         and session_no_end &lt; #{sessionEnd}
</select>