Very simply, because a clause WHERE sales * cost > 100 would look up to "sales" and "cost" in the expression as SELECT fields. Your clause will wotk if you add "sales" and "cost" to the SELECT fields, but that would not be economical: - you don't need them in the result - you will execute the caclulation twice In any case it good personal hygiene to use aliases Ignatius _________________________ ----- Original Message ----- From: "Ross Honniball" <ross@xxxxxxxxxxxxxxxxxxx> To: "php DB" <php-db@xxxxxxxxxxxxx> Sent: 01 December 2004 10:53 Subject: Use of 'as' name in where sub-clause > Hi All, > > In MySql, you CAN'T do the following: > > SELECT sales * cost AS total WHERE total > 100 > > Instead, you need to say: > > SELECT sales * cost AS total WHERE sales * cost > 100 > > > I'm just curious WHY you can't do it. You can, for example, specify ORDER > BY total. > > I can't think of any reason why it would be either difficult or ambiguous > for the SQL engine to allow you to use your calculated field name in the > WHERE part of the query. > > If someone can give me a good reason why this is so, it will stop it > annoying me so much. > > Regards ... Ross > . > . Ross Honniball. JCU Bookshop Cairns, Qld, Australia. > . > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php