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

Join question

Status
Not open for further replies.

sjh

Programmer
Oct 29, 2001
263
US
Hi, I have two tables: tblYears and tblCosts
tblYear
year

tblCosts
year
costs

tblYears contains year values from 2004 – 2018 (15 year period).
tblCosts contains costs for each year values, but it may cover only partial year periods. (i.e. from only 2004-2013).

But I would still like to see the query return the cost for all 15 years. I tried to do a Join (include all records from tblYears and only those records from tblCosts where the joined fields are equal), but I still don’t get all 15 years.

Please help!

Thank you!
SJH
 
SJH,

You want an OUTER join with ALL the rows from tblYear and only the rows that match from tblCosts.

Skip,

[glasses] [red]Be advised:[/red] When transmitting sheet music...
If it ain't baroque, don't fax it! [tongue]
 
Something like this ?
SELECT Y.year, C.costs
FROM tblYear Y LEFT JOIN tblCosts C ON Y.year=C.year
;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top