Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
eject
Starting Member
2 Posts |
Posted - 2006-11-29 : 23:21:34
|
| Hi, i'm newbie to sql..my first project is to create a record which will call information from 2 tables? but some info must refer to other table to get the value.Here is the codeSELECT HREMPN, F02EPNAM, SHIFT, HRSECT, HRLOCTNO, F03EPNAM1, F03EPNAM2FROM dbo.TIMSbut HRLOCTNO must refer to other table named dbo.HRTAB where in HRTAB got 2 fields = HRNO, HRCODEHRLOCTNO from TIMS will may contain same value in HRNO from HRLOCTABi want to retrive the HRCODE value from HRTAB where the HRNO contain same value as HRLOCTNO from TIMS.(HRNO=HRLOCTNO)the result would be like this..HREMPN, F02EPNAM, SHIFT, HRSECT, HRCODE, F03EPNAM1, F03EPNAM2can someone please help to solve my 1st problem.. |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-30 : 00:09:48
|
| Yes. Read about INNER JOIN and LEFT JOIN in Books Online.Peter LarssonHelsingborg, Sweden |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-11-30 : 00:33:53
|
| SELECT a.HREMPN, a.F02EPNAM, a.SHIFT, a.HRSECT, b.HRCODE, a.F03EPNAM1, a.F03EPNAM2FROM dbo.TIMS aLEFT JOIN dbo.HRLOCTAB b ON b.HRNO = a.HRLOCTNOPeter LarssonHelsingborg, Sweden |
 |
|
|
eject
Starting Member
2 Posts |
Posted - 2006-11-30 : 01:17:18
|
| Thanks Peso..really apprieciate dat..:) |
 |
|
|
|
|
|
|
|