MySQL - using 'from_' function - 'Every derived table must have its own alias'
Sorry, I should of mentioned..while this is using the flask-peewee wrapper, I've updated peewee to the most recent version (git clone) and am still experiencing the issue described above, and believe that if I were to re-write this test to use purely peewee, this issue would still be experienced.
 Have you tried applying an alias to the inner query?

```
user_id = SQL("inner_query.user_id")
result_list = SQL("inner_query.result_list")
results = ResultSet.select(
    fn.Group_Concat(result_list).alias("result_list_n")
).from_(
    ResultSet.select(
        ResultSet.user.alias("user_id"),
        ResultSet.result.alias("result_list")
    ).
    order_by(
        ResultSet.result.asc()
    ).
    limit(
        5
    ).
            alias('inner_query')
).group_by(user_id).first().result_list_n
```

On Mon, Apr 7, 2014 at 3:24 AM, Seidr notifications@github.com wrote:

> Sorry, I should of mentioned..while this is using the flask-peewee
> wrapper, I've updated peewee to the most recent version (git clone) and am
> still experiencing the issue described above, and believe that if I were to
> re-write this test to use purely peewee, this issue would still be
> experienced.
> 
> ## 
> 
> Reply to this email directly or view it on GitHubhttps://github.com/coleifer/peewee/issues/336#issuecomment-39706110
> .
 Wow - I'm sure I had tried that..

Thanks for getting back to me, and indeed aliasing the inner query solves the problem.

While playing around with the 'from_' function that was introduced recently (I believe it was pretty recent (see https://groups.google.com/forum/#!topic/peewee-orm/FSHhd9lZvUE), and ran into a bit of an issue when attempting to use the same query that worked under SQLITE, on a MySQL database.

The issue is - as the error message describes - that the table that is derived after using the 'from_' function is not provided with an alias.

Please see the below link to a gist that demonstrates this issue. Using SQLITE, upon visiting the root of the app (http://localhost:5000) you will get a list of IDs resulting from the Group_Concat (1,2,3,4,5). When running the same script, while using the MySQL config, you will get the following error upon visiting the root of the app.

"OperationalError: (1248, 'Every derived table must have its own alias')"

A solution would be to have an alias pool for queries that make use of the 'from_' function, for nested queries.

A test to demonstrate an error when using nested queries in peewee (MySQL): https://gist.github.com/Seidr/10016077

While I can work around this by performing the Group_Concat outside of peewee (i.e. just creating the list by looping over the result set), it'd be nice to be able to alias nested queries within peewee.

If you need any more information, do let me know, and I'll be happy to help.
