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.