Select (SQL): Difference between revisions

Content deleted Content added
m Query evaluation ANSI: lang="postgresql"
Line 666:
 
{{ordered list
|1=<syntaxhighlight lang="sqlpostgresql">
select g.*
from users u inner join groups g on g.Userid = u.Userid
Line 676:
|3= the ON clause is evaluated for vtable1; only records which meet the join condition g.Userid = u.Userid are inserted into Vtable2
|4= If an outer join is specified, records which were dropped from vTable2 are added into VTable 3, for instance if the above query were:
<syntaxhighlight lang="sqlpostgresql">
select u.*
from users u left join groups g on g.Userid = u.Userid
Line 684:
|5= the WHERE clause is evaluated, in this case only group information for user John Smith would be added to vTable4
|6= the GROUP BY is evaluated; if the above query were:
<syntaxhighlight lang="sqlpostgresql">
select g.GroupName, count(g.*) as NumberOfMembers
from users u inner join groups g on g.Userid = u.Userid
Line 691:
vTable5 would consist of members returned from vTable4 arranged by the grouping, in this case the GroupName
|7= the HAVING clause is evaluated for groups for which the HAVING clause is true and inserted into vTable6. For example:
<syntaxhighlight lang="sqlpostgresql">
select g.GroupName, count(g.*) as NumberOfMembers
from users u inner join groups g on g.Userid = u.Userid