SELECT
mld.*
FROM man_loc_detl mld
LEFT JOIN man_node mn ON mld.node_id = mn.id
WHERE 1=1
AND (CHARINDEX(#{nodeId}, ','+mn.path+',') > 0 OR mn.id = #{nodeId})
and mld.loc_no like concat('%',#{locNo},'%')
and mld.matnr like concat('%',#{matnr},'%')
and mld.maktx like concat('%',#{maktx},'%')
ORDER BY mld.create_time DESC
select top 1 *
from man_loc_detl
where 1=1
and anfme > 0
and node_id = #{nodeId}
and matnr = #{matnr}
order by create_time asc
select sum(anfme) as count from man_loc_detl where 1=1 and matnr = #{matnr}
update man_loc_detl
set anfme = anfme - #{anfme}
where 1=1
and node_id = #{nodeId}
and matnr = #{matnr}
delete from man_loc_detl
where 1=1
and node_id = #{nodeId}
and matnr = #{matnr}
select
mld.*
from man_loc_detl mld
left join man_prior mp on mld.node_id = mp.node_id
where 1=1
and mld.node_id = #{nodeId}
and mld.matnr = #{matnr}
and mld.anfme > 0
and mp.status = 1
order by mp.prio desc, mld.create_time asc