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 |
|
quantass
Starting Member
5 Posts |
Posted - 2005-06-16 : 03:33:17
|
| I just cant seem to get my SQL query to return back the correct results.Below is a query using LEFT JOIN. There are 2 tables, mytracker and users. I left join on there respective IDs. There can be IDs within mytracker which no longer exist in the user table but i still do want the entire fields of both tables shown. What i get back is strange. The correct records are returned however for each field belonging to the Users table the value is NULL. I can understand this for unmatched records but this is occurring for every record. Why?select * from mytracker left join users on mytracker.manager_id=users.empid |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-06-16 : 03:41:45
|
| Try left outer joinOtherwise post sample data with expected outcomeMadhivananFailing to plan is Planning to fail |
 |
|
|
LarsG
Constraint Violating Yak Guru
284 Posts |
Posted - 2005-06-16 : 03:59:21
|
| Left outer join is the same as left join so that will not make any difference. - you may be joining on the wrong column- the users tabke may be empty |
 |
|
|
RM
Yak Posting Veteran
65 Posts |
Posted - 2005-06-16 : 07:14:22
|
quote: There can be IDs within mytracker which no longer exist in the user table but i still do want the entire fields of both tables shown.
The ids which no longer exists in the user table will not be returned with left join. Try Full Join on the Id to return the ids of both the tables |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2005-06-16 : 07:14:40
|
| I would have to say you have some bad data in the tables.*need more coffee*SELECT * FROM Users WHERE CLUE > 0(0 row(s) affected) |
 |
|
|
|
|
|