SELECT m.customer_id,
smm.mid
FROM merchant m
JOIN sponsor_merchant_mid smm ON smm.merchant_id = m.id
WHERE m.customer_id IN (1)
UNION ALL
SELECT m.customer_id,
rsmm.mid
FROM merchant m
JOIN reporting_sponsor_merchant_mid rsmm ON rsmm.merchant_id = m.id
WHERE m.customer_id IN (1);