-- 后端Sql 改造User SELECT*from `user` u LEFTJOIN (select u.id, SUM(o.price DIV 1000) jifen fromUser u ,order_info o where u.id = o.user_id and price >=1000GROUPBY nickname) as j on u.id = j.id -- xml SELECT*from `user` u LEFTJOIN (select u.id, SUM(o.price DIV 1000) jifen fromUser u ,order_info o where u.id = o.user_id and price >=1000GROUPBY nickname) as j on u.id = j.id -- Api sql select*,(o.price DIV 1000) as jifen from order_info o , `user` u where o.user_id = u.id and o.payment_flag =1and o.user_id =362791 SELECT *, (o.price DIV 1000) AS jifen FROM order_info o WHERE o.payment_flag =1 AND o.user_id =362791 --xml select*,(o.price DIV 1000) as jifen from order_info o , `user` u where o.user_id = u.id and o.payment_flag =1and o.user_id = #{userid,jdbcType=INTEGER}
<selectid="selectJifenbyId"parameterType="java.lang.Integer"resultMap="BaseResultMap"> select *,(o.price DIV 1000) as jifen from order_info o , `user` u where o.user_id = u.id and o.user_id = #{userid,jdbcType=INTEGER} </select>