java sql映射文件 如何传多个parameterclass_Mybatis传递多个参数的几种方式

#{}里面的名称对应的是Map里面的key名称。

这种方法适合传递多个参数,且参数易变能灵活传递的情况。

PS:

MyBatis传递map参数时,如果传递参数中没有对应的key值,在执行sql语句时默认取的是null

例如:map中没有put “name”这个key,在sql中使用#{name}时,默认赋值null

Java Bean传参法

public User selectUser(User params);select * from user

where user_name = #{userName} and dept_id = #{deptId}

#{}里面的名称对应的是User类里面的成员属性。

这种方法很直观,但需要建一个实体类,扩展不容易,需要加属性,看情况使用。

SELECT top 10000 tol.TuhuCost,tol.BaseCost,tol.OrderID AS OrderListOrderID,torp.ChildrenOrderId, torp.ParentOrderId,tol.pkid as OrderListID,torp.RelationshipType,tor.InstallShopID,tor.WareHouseID

FROM dbo.tbl_OrderRelationship AS torp WITH(NOLOCK)

LEFT JOIN dbo.tbl_OrderList AS tol WITH(NOLOCK)

ON torp.ParentOrderId = tol.OrderID

left JOIN vw_tbl_order as tor ON torp.ParentOrderId=tor.PKID

WHERE torp.CreateDatetime>='2019-11-29'

AND torp.RelationshipType = 1

AND tor.InstallShopID IS NOT NULL

AND tor.InstallShopID<>tor.WareHouseID

AND tor.Status<>'7Canceled'

AND tol.TuhuCost is not NULL

ORDER BY torp.CreateDatetime DESC

SELECT COUNT (1) as cnt FROM (

SELECT DISTINCT tol.OrderID

FROM dbo.tbl_OrderRelationship AS torp WITH(NOLOCK)

LEFT JOIN dbo.tbl_OrderList AS tol WITH(NOLOCK)

ON torp.ParentOrderId = tol.OrderID

left JOIN vw_tbl_order as tor ON torp.ParentOrderId=tor.PKID

WHERE torp.CreateDatetime>='2019-11-29'

AND torp.RelationshipType = 1

AND tor.InstallShopID IS NOT NULL

AND tor.InstallShopID<>tor.WareHouseID

AND tor.Status<>'7Canceled' AND tol.baseCost=0

AND tol.TuhuCost is not NULL ) as t1

SELECT COUNT(1) as cnt from tbl_orderlist as t1 with(nolock)  left join vw_tbl_order as t2 with(nolock) ON t1.orderid=t2.pkid WHERE t2.OrderDatetime>='2019-12-01'  AND t1.cost>0 AND t1.baseCost=0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值