如果enrollDate和cancelDate相同,我需要消除行。所以我写了如下查询
SELECT a.id, a.clientId, a.enrollDate, a.cancelDate FROM gap_borrower a WHERE STR_TO_DATE( a.
{loanEndDate {1}} {enrollDate {1}} {cancelDate {1}}
但是如果cancelDate是Null,它没有显示为不同。(只需要消除上图中的id = 8551。这是我的问题)所以我用if条件写了另一个查询
, '%Y-%m-%d' ) >= STR_TO_DATE( '2015-12-31', '%Y-%m-%d' ) AND FIND_IN_SET( a.status, 'A,C' ) AND STR_TO_DATE( a.
它也失败了。请指导我解决这个问题
答案 0 :(得分:1)
尝试类似的东西:
SELECT a.id, a.clientId, a.enrollDate, a.cancelDate
FROM gap_borrower a WHERE
DATE(a.loanEndDate) >= DATE('2015-12-31')
AND FIND_IN_SET( a.status, 'A,C' )
AND (DATE(a.enrollDate) <> DATE(a.cancelDate) OR a.enrollDate IS NULL OR a.cancelDate IS NULL)
--uncomment this if you don't need rows where the both dates are null
--AND (a.enrollDate IS NOT NULL or a.cancelDate IS NOT NULL)