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 |
|
cdnapps
Starting Member
1 Post |
Posted - 2010-08-28 : 17:28:21
|
| I have a table called Leaves. Fields are, * LeaveID * PersonID * ActingPersonIDIn Person's table, I have, * PersonalID * EmployeeCode * PersonNameNow, in the datagrid, I need to show, * PersonEmployeeCode * PersonName * ActingPersonEmployeeCode * ActingPersonNameNow, I know how to write the SQL Join to get the data populated. But, the problem is, in some cases, there won't be any acting person. In which case, I need to display data, * PersonEmployeeCode = 0001 * PersonName = John * ActingPersonEmployeeCode = - * ActingPersonName = No acting PersonNow, I am stuck here. How do I do a conditional join statement?I really need a quick help on this...RegardsKush |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-08-28 : 18:51:03
|
LEFT JOIN will return NULL if there is no matching record.So you can use ISNULL() or COALESCE(). No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|
|