Problem with count(*) in mybatis

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

Problem with count(*) in mybatis

roy
i'm facing problem with count(*) in mybatis ... it is always returning
0...

<select id="checkGeoAreaStatusIsInActive" resultType="int"
                parameterType="int">
                select count(geo_area_id) from GEO_AREA
                where status != 'inactive' and geo_area_id = #{value,
jdbcType=INTEGER}
        </select>

i have tried to change the query as below but still facing issues.

<select id="checkGeoAreaStatusIsInActive" resultType="int"
                parameterType="int">
                select count(*) geo_area_id from GEO_AREA
                where status != 'inactive' and geo_area_id = #{value,
jdbcType=INTEGER}
        </select>
Reply | Threaded
Open this post in threaded view
|

Re: Problem with count(*) in mybatis

Larry Meadors
Try this instead:

select count(*) as value from ...

Larry


On Fri, Feb 3, 2012 at 12:39 AM, geetha <[hidden email]> wrote:

> i'm facing problem with count(*) in mybatis ... it is always returning
> 0...
>
> <select id="checkGeoAreaStatusIsInActive" resultType="int"
>                parameterType="int">
>                select count(geo_area_id) from GEO_AREA
>                where status != 'inactive' and geo_area_id = #{value,
> jdbcType=INTEGER}
>        </select>
>
> i have tried to change the query as below but still facing issues.
>
> <select id="checkGeoAreaStatusIsInActive" resultType="int"
>                parameterType="int">
>                select count(*) geo_area_id from GEO_AREA
>                where status != 'inactive' and geo_area_id = #{value,
> jdbcType=INTEGER}
>        </select>
Reply | Threaded
Open this post in threaded view
|

Re: Problem with count(*) in mybatis

c c-2
In reply to this post by roy

first you must know if it has data in you table ?

 1,you can print the sql
2, excute the sql use some db tools ,




2012/2/3 geetha <[hidden email]>
i'm facing problem with count(*) in mybatis ... it is always returning
0...

<select id="checkGeoAreaStatusIsInActive" resultType="int"
               parameterType="int">
               select count(geo_area_id) from GEO_AREA
               where status != 'inactive' and geo_area_id = #{value,
jdbcType=INTEGER}
       </select>

i have tried to change the query as below but still facing issues.

<select id="checkGeoAreaStatusIsInActive" resultType="int"
               parameterType="int">
               select count(*) geo_area_id from GEO_AREA
               where status != 'inactive' and geo_area_id = #{value,
jdbcType=INTEGER}
       </select>