query the top N users with the largest number of courses, and the number of courses should also be queried
the corresponding sql is as follows:
<select id="getUserWithMostFans" resultMap="">
SELECT t.userId,t.selectNum
FROM
(
SELECT
userId,
count(course) AS selectNum
FROM
user_course
GROUP BY
userId
ORDER BY
selectNum
) t LIMIT 10
question:
1. How do I receive the return value?
of course you can use map to receive the return value, but map is generally not recommended.
in addition, if you define a resultMap, you also need to specify a type
<resultMap id="" type="?????">
<result />
<result />
</resultMap>
if so, you also need to define another object .
2. If you define another object, does that object count as DO? Or should it be treated as VO?
VO is obviously not appropriate either. And DO corresponds to the database field one by one, so the return result of the database should not belong to the category of DO, right?
I hope you can give me a lot of help. Thank you!