例如:
Cnd cnd = Cnd.where( Cnd.exps( "wai.user_id" , "=" , userId ).and("wmt.agent_id","is",null) ).and( "trans_type" , "not in",(1,2,3))
在后面继续添加一个条件
cnd.and("wai.user_id = wmt.receive_user_id "," "," ");
cnd.and("wai.user_id" , "=" , "wmt.receive_user_id");
上面会导致 sql 执行 条件后面会有一个空引号 数据拿不到
下面导致 wmt.receive_user_id 这个上面有引号 还是拿不到数据
请问 怎样用and() 去添加这种已知的条件 ?
下面是我的sql
SELECT
wmt.id as walletTransId,-- 交易记录ID
wmt.service_order_id AS orderId -- 订单号
,
om.order_code AS orderCode -- 订单编码
,
om.order_status AS orderStatus -- 订单状态
,
date_format(
wmt.reg_time,
"%Y-%m-%d %H:%i:%S"
) AS regTime -- 发生时间
,
wmt.trans_type AS transType -- 类型
,
wmt.memo AS memo -- 备注 即主题
,
CASE
WHEN wai.user_id = wmt.receive_user_id THEN
"收入"
WHEN wai.user_id = wmt.user_id THEN
"支出"
else
"支出"
END AS type,
wmt.trans_money/100 AS transMoney -- 金额
,
wmt.trans_status AS transStatus -- 交易状态
FROM
wallet_money_transactions wmt
LEFT JOIN wallet_account_info wai ON wmt.wallet_id = wai.id
LEFT JOIN order_main om ON om.id = wmt.service_order_id
WHERE (wai.user_id=16 AND wmt.agent_id IS NULL ) AND trans_type NOT IN (21,22,11) AND wai.user_id = wmt.receive_user_id
order by wmt.id desc