67,538
社区成员
发帖
与我相关
我的任务
分享and ( to_char(t.createtime,'yyyy-mm-dd' ) between to_char(sysdate'yyyy-mm-dd' ) and to_char(sysdate'yyyy-mm-dd' ))
and not exists(
select 1 from t_merchant c where c.merchant_id = t.merchant_id
)
<select id="getMerchantByPos" resultMap="PosMap">
select
T.MERCHANT_ID
from T_POS T
<where>
1=1
<if test="startTime != null and endTime != null ">
AND ( TO_CHAR(T.CREATETIME,'yyyy-mm-dd' ) BETWEEN TO_CHAR(sysdate'yyyy-mm-dd' ) AND TO_CHAR(sysdate'yyyy-mm-dd' ))
AND SELECT c.* FROM T_MERCHANT C WHERE C.MERCHANT_ID not IN ( select distinct T.MERCHANT_ID AS ID2 from t_pos T where
(TO_CHAR(T.CREATETIME, 'yyyy-mm-dd') BETWEEN TO_CHAR(sysdate 'yyyy-mm-dd') AND TO_CHAR(sysdate 'yyyy-mm-dd')))
</if>
</where>
</select>
是mysql么?
是要拿开始时间(startTime)和结束时间(endTime)之间的数据吗?拼SQL的时候不应该这么写吧:“AND SELECT c.* FROM T_MERCHANT C ”。select查出来的结果集应该在where子句外面。select a.*,b.* from a,b 这种的。
建议把执行SQL打印出来,放到客户端执行,这样一看便知错误在哪里了。