| Author |
Topic |
|
vkkishore_s
Starting Member
5 Posts |
Posted - 2010-03-31 : 00:52:08
|
| Dear AllCan any body tell me how to left outer join a table with empty tablein my query i am join a table employee emp_code is a primary keywith AmcAssignedEmployee on right i am getting a result set if there is no condition in where clause .if i keep a condition in where clause every thing failedemployee tableemp_code,emp_name ,emp_lname-----------------------------1 abcd xyz2 sss ijkAmcAssignedEmployee table blank tableemp_code ,assignId------------------ --- 0 records------------------my query is select e.emp_code As EmpId,AssignedAMCID from employee Efull outer join AmcAssignedEmployee AEon e.emp_code=AE.emp_code Now if i insert one row in AmcAssignedEmployee as belowAmcAssignedEmployee table blank tableemp_code ,assignId------------------ --- 0 records1 12 NULL3 NULL4 NULL... So On------------------SELECT e.emp_code As EmpId,AssignedAMCID from employee Efull outer join AmcAssignedEmployee AEon e.emp_code=AE.EmpCodeupto here its working fine, but now if i use the below lines everything is failed (i want to get the records whose assignId is not 1)where AE.AssignedAMCID<>1Please advise me Thanks and RegardsKrishna Kishore |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2010-03-31 : 00:59:49
|
| Do you mean the AmcAssignedEmployee table is empty?Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
vkkishore_s
Starting Member
5 Posts |
Posted - 2010-03-31 : 02:00:08
|
| Yes,AmcAssignedEmployee is not having any records |
 |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2010-03-31 : 02:07:53
|
| what is your expected result? |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2010-03-31 : 02:26:44
|
quote: Originally posted by vkkishore_s Yes,AmcAssignedEmployee is not having any records
Why you want to join an empty table? and how u think it can possible?Senthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2010-03-31 : 02:28:41
|
| If you want an empty column you can try thisselect *,null as empty_record from table_nameSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
 |
|
|
vkkishore_s
Starting Member
5 Posts |
Posted - 2010-03-31 : 02:41:22
|
| Thanks senthil thanks for reply.My second table is not an empty table (this is not my question)i want to check the value of a column which is a null column after doing left outer join .My only question is i am gettting null values for un matched records .i want to get the records beased on the below conditionAssignedAMCID =1 (1 is for matching records)or AssignedAMCID <> 1 (i should get the unmatched records, other than the records having one) |
 |
|
|
AndrewMurphy
Master Smack Fu Yak Hacker
2916 Posts |
Posted - 2010-03-31 : 03:35:51
|
| This "where AE.AssignedAMCID<>1" converts the query into an "inner join"convert this statement into an "ON" clause. |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-03-31 : 03:58:34
|
"AssignedAMCID <> 1 (i should get the unmatched records, other than the records having one)"(AssignedAMCID <> 1 OR AssignedAMCID IS NULL) maybe? |
 |
|
|
|