Last active
July 9, 2020 12:08
-
-
Save prgTW/1908657ce77e859b79a7fd4b76da6c43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT 1 | |
FROM `agreement` | |
LEFT JOIN `product1` ON ( | |
`agreement`.`id`=`product1`.`agreement_id` | |
AND `product1`.`status` IN ('active', 'expiring') | |
) | |
LEFT JOIN `product2` ON ( | |
`agreement`.`id`=`product2`.`agreement_id` | |
AND `product2`.`status` IN ('active', 'expiring') | |
) | |
WHERE `agreement`.customer_id = :id | |
GROUP BY agreement.id | |
HAVING count(product1.id) > 0 OR count(product2.id) > 0 | |
LIMIT 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment