优化商品查询的sql,优化group by语句
This commit is contained in:
@@ -39,12 +39,11 @@
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="selectByConditionMaterial" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultMapList">
|
<select id="selectByConditionMaterial" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultMapList">
|
||||||
select m.*,u.name unitName, mc.name categoryName, me.bar_code,
|
select jm.*, u.name unitName, mc.name categoryName, jme.bar_code,
|
||||||
me.purchase_decimal, me.commodity_decimal, me.wholesale_decimal,me.low_decimal,me.sku
|
jme.purchase_decimal, jme.commodity_decimal, jme.wholesale_decimal, jme.low_decimal, jme.sku
|
||||||
FROM jsh_material m
|
from (select m.id, min(me.id) meId
|
||||||
left JOIN jsh_material_extend me on m.id = me.material_id and ifnull(me.delete_Flag,'0') !='1'
|
from jsh_material m
|
||||||
left JOIN jsh_unit u on m.unit_id = u.id and ifnull(u.delete_Flag,'0') !='1'
|
left join jsh_material_extend me on m.id = me.material_id and ifnull(me.delete_Flag,'0') !='1'
|
||||||
left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
|
|
||||||
where 1=1
|
where 1=1
|
||||||
<if test="materialParam != null and materialParam !=''">
|
<if test="materialParam != null and materialParam !=''">
|
||||||
<bind name="bindKey" value="'%'+materialParam+'%'"/>
|
<bind name="bindKey" value="'%'+materialParam+'%'"/>
|
||||||
@@ -106,7 +105,12 @@
|
|||||||
</if>
|
</if>
|
||||||
and ifnull(m.delete_flag,'0') !='1'
|
and ifnull(m.delete_flag,'0') !='1'
|
||||||
group by m.id
|
group by m.id
|
||||||
order by m.id desc
|
order by m.id desc) tb
|
||||||
|
left join jsh_material jm on tb.id = jm.id and ifnull(jm.delete_Flag,'0') !='1'
|
||||||
|
left join jsh_material_extend jme on tb.meId = jme.id and ifnull(jme.delete_Flag,'0') !='1'
|
||||||
|
left join jsh_unit u on jm.unit_id = u.id and ifnull(u.delete_Flag,'0') !='1'
|
||||||
|
left join jsh_material_category mc on jm.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
|
||||||
|
order by tb.id desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertSelectiveEx" parameterType="com.jsh.erp.datasource.entities.Material" useGeneratedKeys="true" keyProperty="id">
|
<insert id="insertSelectiveEx" parameterType="com.jsh.erp.datasource.entities.Material" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
|||||||
Reference in New Issue
Block a user