Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

explain a select statement

Status
Not open for further replies.

dumdum2

Programmer
Mar 18, 2000
98
GB
Can someone explain what this select statement means...?

SELECT [dates and wl].*, (select top 1 rsvid FROM [Dates and wl] b where b.studio=[Dates and wl].studio and b.res_begin>=[Dates and wl].res_end order by b.res_begin) AS nextrsvid
FROM [dates and wl];


What is 'b' ?

Thanks!
 
b is an alias for the 2nd instance of the [Dates and wl] table.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
it allows for a correlated sub query (a subquery that is related to the "main" query).

SELECT (all the fields from [dates and wl])
and
(the field RSVID from the same table where the studio matches the outer query and the res_begin is greater than res_end: name this field nextRSVID)

HTH
Leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top