有人可以解释一下吗。我的 SQL:
SELECT
`offers`.`id`,
`offers`.`max_available`,
(SELECT COUNT( coupons.id ) FROM coupons WHERE coupons.status = 'Y' AND coupons.offer_id = offers.id) AS coupons_sold
FROM
`offers`
WHERE
`offers`.`status` IN ('P', 'S') AND
`offers`.`published_at` < 1341612000 AND
`offers`.`end_at` >1341567914 AND
`coupons_sold` < `offers`.`max_available`
ORDER BY `offers`.`created_at` DESC
LIMIT 4 OFFSET 0
这将返回我这 4 行:
id max_available coupons_sold
195 19 20
194 9999 0
193 9999 0
159 9999 93
ID 195
如果我在 where 有这种情况,怎么可能包含该行coupons_sold < offers.max_available
?我一无所知!