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 |
|
Mikk2007
Starting Member
1 Post |
Posted - 2007-10-07 : 17:55:44
|
| hiI have data in two tables. NAMESID Name1 FIRST2 SECONDCODESID CodeType Code1 A xyz1 B abc1 C gfd2 A xdz2 B dcaI want to join the two tables to add the Code of CodeType "C" to the records of NAMES Result ExampleID Name Code1 FIRST gfd2 SECOND ----I want to have all records from the names with the codetype C, if there is no record with the codetype c for a given ID, the cell should be blank to identify for which ID's the CodeType C is mising.how should the sql statement look like?Please help!thanks in advance!Mikk |
|
|
jezemine
Master Smack Fu Yak Hacker
2886 Posts |
Posted - 2007-10-07 : 22:32:38
|
select n.id, n.name, c.codefrom names nleft join codes c on n.id=c.id and c.codetype='C' elsasoft.org |
 |
|
|
|
|
|