Because "discount" isn't one of:
1) a field on one of the tables your query is based on
2) a formula based on one or more of the fields from one or more of the 
tables your query is based on.

What it is: an alias to the results of a function applied to 2 fields on 
one of your tables. 

Since the name "discount" is a reference to some of the *results* of this 
particular query, it will be impossible for the WHERE clause to use the 
RESULTS of a query to determine what rows should PARTICIPATE in the query 
(WHERE clauses are evaluated BEFORE aliases are determined).

It's kind of like trying to drink from a glass before you fill it up. 
Understand?

Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine

"Ed Lazor" <[EMAIL PROTECTED]> wrote on 10/11/2004 04:33:27 PM:

> I'm getting an unknown column error for discount with the following 
query.
> Any idea why?
> 
> -Ed
> 
> SELECT ID, Title, MSRP, Price, round( ( (MSRP - Price) / MSRP) * 100) as
> discount
> FROM `products`
> where discount > '10'
> limit 10
> 
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
> 

Reply via email to