title: MyBatis reuse query to get count(*)
body: <p>I have a big search query defined in my XML file</p>
  
  <pre><code>&lt;select id="searchItems" resultMap="myMap" parameterType="map"&gt;
  SELECT
    a lot of field
  FROM multiple table with few joins
  WHERE with few conditions
  LIMIT x,y
  &lt;/select&gt;
  </code></pre>
  
  <p>The query above uses limit to be able to return paginate result and avoid returning the entire items on a search. But for a requirement I also need to return the total number of item found by the query.</p>
  
  <p>My question is: How can I reuse the query above to instead just select count(*) and obviously without the LIMIT? Is there a way to separate each query part and reuse them in a <code>&lt;select&gt;</code> tag ?</p>