如何从多列中获取单列?
How can I get single column from multiple columns?
我有一个类似这样的查询。
<select id="select..." resulType="???">
SELECT
COUNT(1) AS count,
NAME AS name
FROM
...
GROUP BY
...
ORDER BY
count ASC
</select>
我实际上需要按顺序获取那些 name
,我希望我的映射器界面看起来像这样。
/**
* Lists names ordered by ... count.
* ...
*/
List<String> select...(...);
我该怎么做?需要什么类型的 resultType
?
我需要指定的 resultMap
吗?
你可以提一下resultType="string"
。
例如,我尝试了以下查询:
<select id="getCountriesSortedByLanguages" resultType="string">
SELECT c.name, count(cl.language)
FROM country c
JOIN countrylanguage cl ON cl.countrycode = c.code
GROUP BY c.code
ORDER BY 2 DESC
</select>
我的映射器定义为:
public List<String> getCountriesSortedByLanguages();
我有一个类似这样的查询。
<select id="select..." resulType="???">
SELECT
COUNT(1) AS count,
NAME AS name
FROM
...
GROUP BY
...
ORDER BY
count ASC
</select>
我实际上需要按顺序获取那些 name
,我希望我的映射器界面看起来像这样。
/**
* Lists names ordered by ... count.
* ...
*/
List<String> select...(...);
我该怎么做?需要什么类型的 resultType
?
我需要指定的 resultMap
吗?
你可以提一下resultType="string"
。
例如,我尝试了以下查询:
<select id="getCountriesSortedByLanguages" resultType="string">
SELECT c.name, count(cl.language)
FROM country c
JOIN countrylanguage cl ON cl.countrycode = c.code
GROUP BY c.code
ORDER BY 2 DESC
</select>
我的映射器定义为:
public List<String> getCountriesSortedByLanguages();