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 |
|
adam_hh
Starting Member
6 Posts |
Posted - 2007-04-04 : 16:47:05
|
| I've got two tables, I want to list the employee record from empper and all associated records in empdepnd. When I run my sql below, all I see are the empdepnd records. How can I get it to show me the record from empper plus associated empdepnd records?select a.emp_id, a.last_name, b.emp_id2, b.last_name2 from empper a inner join (select emp_id as emp_id2,last_name as last_name2 from empdepnd) b on a.emp_id = b.emp_id2where a.company = 'ABC' and a.pers_status = 'A' and a.emp_id = 1234 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-04 : 17:58:43
|
your query looks fine.Try posting the table DDL, some sample data and the expected result. KH |
 |
|
|
adam_hh
Starting Member
6 Posts |
Posted - 2007-04-04 : 19:54:11
|
| All I get are the records from the empdepnd table and no records from the empper table. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-04 : 21:37:06
|
quote: Originally posted by adam_hh All I get are the records from the empdepnd table and no records from the empper table.
You are using INNER JOIN. You will get records from both table that matches on emp_id column. How can the query only listed records from empdepnd table and not empper table ?As said. Post your table DDL, sample data and required result. KH |
 |
|
|
|
|
|