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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help needed writing a query 1

Status
Not open for further replies.

fergmj

Programmer
Feb 21, 2001
276
US
Hi I need some help writing a query

I have two tables in my database
SCHEDULE and STAFF
I have a query that extracts data from SCHEDULE:
SELECT Schedule_No, Rate, StartDate, EndDate, Staff_No FROM dbo.SCHEDULE where Client_No=@Client_No

Staff_No and Staff_Name are the only two columns in the STAFF table.

I want to get the Staff_Name where the Staff.Staff_No = SCHEDULE.Staff_No but as part of the original query above.
 
Code:
SELECT sc.Schedule_No
     , sc.Rate
     , sc.StartDate
     , sc.EndDate
     , st.Staff_Name 
  FROM dbo.SCHEDULE AS sc
INNER
  JOIN dbo.STAFF AS st
    ON st.Staff_No = sc.Staff_No 
 WHERE sc.Client_No = @Client_No

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top