mysql - Complex SQL query with an alias -


i saw complex select statement has several components: aliases , subqueries

select     u.id, u.username, u.active, u.email, u.admin, u.banned, u.name,     (select         group_concat( g.name separator'-groupsep-' ) groups g,         group_memberships gm         g.id = gm.group , gm.user = u.id     ) groupmemberships     users u u.id={$uid} 

the part doesn't make sense me part as groupmemberships.

what aliasing? element follows u.name?

i unfamiliar subquery syntax.

any useful explanation , link official documentation help.

this query using subquery in from clause of query. subquery returns set of rows in turn used table rest of query. in mysql, mandatory give alias 'virtual table'.

so concretely, name groupmemberships refers result set from

   select        group_concat( g.name separator'-groupsep-' )           groups g, group_memberships gm           g.id = gm.group        , gm.user = u.id 

a more detailed explanation can found in the mysql documentation subqueries in clause.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -