我有这个 SQL:
SELECT
`refnumbers`.`order_id`,
`refnumbers`.`deal_id`,
`refnumbers`.`claim_track_id`,
`deals`.`partner_count`
FROM `refnumbers`
JOIN `deals`
ON (`refnumbers`.`deal_id` = `deals`.`ID`)
JOIN `users`
ON (`users`.`id` = `deals`.`partner_id`)
WHERE `refnumbers`.`is_claimed` = '1'
AND `deals`.`partner_id` = '62039'
AND `refnumbers`.`claimed_at` BETWEEN '2013-01-17 00:00:00'
AND '2013-01-17 23:59:59'
ORDER BY `refnumbers`.`claimed_at` DESC
我想选择 deals.partner_id = 62039 IF Deals.partner_count 为 1 的位置。
如果 partner_count 不是 1 那么它应该选择 where refnumbers.claim_track_id = 62039
如何才能做到这一点?