Interesting.  I thought you could sort by aliases.  Thanks Shawn.

The easy answer was to just add the calculation to the where section as
well.  But which approach is faster - "having" or the calculation?

Ie.

select ID, Title, MSRP, Price, round( ( (MSRP - Price) / MSRP) * 100) as
discount from products where round( ( (MSRP - Price) / MSRP) * 100) > 10

- OR - 

select ... HAVING discount > 10

?

> -----Original Message-----
> Great explanation. By the way, Ed, what you might be looking
> for is the HAVING clause, which culls records right before
> the LIMIT is applied.
> 
> SELECT ID, Title, MSRP, Price, round( ( (MSRP - Price) / 
> MSRP) * 100) as 
> discount
> FROM `products`
> HAVING 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