MySQL Forums
Forum List  »  Newbie

Re: Averaging the data?
Posted by: Felix Geerinckx
Date: May 12, 2005 03:08PM

Alan Northam wrote:

> Thanks for the reply but being new to MYSQL I am a little confused.
> Can you explain what f2.d, f1.d, foo, f1, f2 mean?

The query was:

SELECT AVG(f2.d) FROM (SELECT f1.d FROM foo f1 LIMIT 0, 50) f2;

foo is the table

f1 and f2 are aliases for this table (to distinguish them when you need foo more than once in a
query). In SELECT * FROM foo f1 (or equivalent, SELECT * FROM foo AS f1) you assign the alias f1 to foo.

d is the data column, and f1.d and f2.d are the full column specifications (using the aliases).

In the query, the construct (SELECT ... FROM foo ...) f2 is a so-called derived table, which always must have an alias.

--
felix
Please use BBCode to format your messages in this forum.

Options: ReplyQuote


Subject
Written By
Posted
May 12, 2005 12:43PM
May 12, 2005 02:53PM
Re: Averaging the data?
May 12, 2005 03:08PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.