Re: Aliases and the WHERE clause
- From: "Michel Walsh" <vanderghast@VirusAreFunnierThanSpam>
- Date: Sat, 29 Jul 2006 08:47:15 -0400
Hi,
I was thinking about the ORDER BY clause. The WHERE clause behaves exactly
the same way in Jet and in MS SQL Server as neither of the two engines allow
alias in the WHERE clause. If you use the grid, and add a criteria on an
expression, the expression, not the alias, will be copied, for your, in the
WHERE clause.
Technically, that is somehow related to the fact that the WHERE clause is
evaluated BEFORE The SELECT, and thus, the alias is not known when the WHERE
clause is involved.
Vanderghast, Access MVP
"pepenacho" <pepenacho@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:2BFCFAF1-355B-44BF-8210-9153CC88E676@xxxxxxxxxxxxxxxx
Thanks for the response. It certainly helps to know that.
Pepe
"Michel Walsh" wrote:
Hi,
Unfortunately, you can't use alias in the WHERE clause, with JET
(probably a
long time bug that is now unlikely to be fixed because no one (not
enough,
anyway) seems to complain). You have to cut and paste the whole
expression
it aliases (and hope that expression is NOT itself an arithmetic
expression
based on other aliases). Note that MS SQL Server cannot use expression
based
on aliases, so, in the end, we are left with two "half buggy" engines, in
that respect.
Hoping it may help,
Vanderghast, Access MVP
"pepenacho" <pepenacho@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:83CD33B2-72C6-402C-A404-72E6F6928899@xxxxxxxxxxxxxxxx
Hello:
I recently took up the cause of learning ever so much more about SQL,
specifically reading "SQL Queries for Mere Mortals" as well as
"Microsoft
Jet
SQL for Access 2000." The ability to flex a query's muscles in MS
Access
has
come, more than once, very handy.
I ran into trouble with Aliases. For example
SELECT EarningsBeforeInterestAndTax AS Ebit FROM IncomeStatements WHERE
Ebit
0
The problem is: the WHERE clause does not recognize the new Alias. How
come?
It seems that I can successfully alias a table, but not a field?
Thanks,
pepenacho
.
- Follow-Ups:
- Re: Aliases and the WHERE clause
- From: pepenacho
- Re: Aliases and the WHERE clause
- References:
- Re: Aliases and the WHERE clause
- From: Michel Walsh
- Re: Aliases and the WHERE clause
- Prev by Date: Re: Evaluate Next Record In Query?
- Next by Date: Re: Summary Report with related tables
- Previous by thread: Re: Aliases and the WHERE clause
- Next by thread: Re: Aliases and the WHERE clause
- Index(es):
Relevant Pages
|
Loading