mysql@stripped wrote:
> Daevid Vincent wrote:
>
>> Nope. I've only ever use mySQL. I only ever care to use mySQL. mySQL
>> puts in
>> plenty of other features that no other RDBMS has or uses, and other RDBMS
>> have features that mySQL has, so what's the problem. Unless I was porting
>> to/from another RDBMS?
>
>
> This strikes me as a *terrible* reason.
>
> It seems stupid that I can't do that though. I can
>
>> use the alias in the HAVING clause, and also in an ORDER BY clause.
>
>
> Yes, but those are HAVING and ORDER BY clauses. You recognise that they
> are distinct parts of a SELECT statement, so ...
>
> I'm not saying it's a trivial change
>
> So far, i'd say that you're suggesting it is.
>
> http://dev.mysql.com/tech-resources/articles/mysql-views.html
>
> brian
>
I've looked for--but cannot find--a page online that explains this
nicely. Suffice to say that the problem is similar to that of trying to
use a column alias in the WHERE clause. In that case, it's because WHERE
is parsed before the SELECT clause. In your case, it's simply that the
column expressions are constructed more or less as one, not from left to
right or anything like that.
You could also use a derived table here, i should think:
SELECT foo.bar, UNIX_TIMESTAMP(foo.bar) FROM (
SELECT DATE_ADD('2007-10-23', INTERVAL user_access_hours HOUR)
AS bar
FROM end_user_groups
) AS foo;
brian