我的查询:
SELECT *
FROM ranks
WHERE
(price = 25.00 AND accumulate = 0)
OR
(price <= (SELECT SUM(amount) FROM donations WHERE username = 'username' AND amount IN (SELECT price FROM ranks WHERE accumulate = 1)))
ORDER BY price
DESC LIMIT 1
基本上,如果找到匹配项,我想返回第一个 where 子句,否则返回第二个子句。