Sagi Bashari wrote:
Michael Stassen wrote:
No, you can't use an alias in the WHERE clause. Even if you could,
you'd have a problem here. The WHERE clause is used to decide which
rows to look at in advance of any calculations. You're asking mysql
to count the rows which match the WHERE cla
Sagi Bashari <[EMAIL PROTECTED]> wrote:
> Michael Stassen wrote:
>
>> No, you can't use an alias in the WHERE clause. Even if you could,
>> you'd have a problem here. The WHERE clause is used to decide which
>> rows to look at in advance of any calculations. You're asking mysql
>> to count t
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'
Michael Stassen wrote:
No, you can't use an alias in the WHERE clause. Even if you could,
you'd have a problem here. The WHERE clause is used to decide which
rows to look at in advance of any calculations. You're asking mysql
to count the rows which match the WHERE clause, but you're also as