Off the top of my head, I'm sure you'd do it like this:
SELECT products.id, COUNT(orders.id) AS hits FROM products, orders WHERE orders.product_id = products.id AND hits >= products.quantity GROUP BY products.id
Tried that: ERROR 1054: Unknown column 'hits' in 'where clause'
running version 4.0.14-standard-log
Sagi
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]