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 |
derrellgore
Starting Member
6 Posts |
Posted - 2012-02-17 : 21:19:35
|
Here is what I am trying to accomplish. With just one of the LEFT JOINs I get one line per record. With both left joins I get multiple lines for each record so I know I am not doing something right. Can anyone help with this? EXAMPLE: SELECT Account#, SalesmanNum, SALEMAN.Name, Netterms, NETINFO.Netdays FROM ACCOUNTINFO LEFT JOIN SALESMAN on ACCOUNTINFO.SalesmanNum = SALESMAN.SNUM LEFT JOIN NETINFO on ACCOUNTINFO.Netterms = NETINFO.Nterms |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-02-17 : 21:36:27
|
maybe a join condition between SALESMAN and NETINFO ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
derrellgore
Starting Member
6 Posts |
Posted - 2012-02-17 : 21:49:18
|
No connection between SALESMAN and NETINFO |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-02-17 : 21:54:47
|
then what is the relationship between ACCOUNTINFO and NETINFO ?is it 1 to 1 ? KH[spoiler]Time is always against us[/spoiler] |
 |
|
derrellgore
Starting Member
6 Posts |
Posted - 2012-02-17 : 22:05:47
|
For each record I am wanting to add two fields SALESMANNAME and NETDAYS.ACCOUNTINFO joins SALESMAN to get SALESMAN.NAMEACCOUNTINFO joins NETINFO to get NETINFO.NETDAYS. |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-02-18 : 07:09:56
|
please show us some sample data from each of the table and the expected result KH[spoiler]Time is always against us[/spoiler] |
 |
|
derrellgore
Starting Member
6 Posts |
Posted - 2012-02-18 : 10:13:55
|
ACCOUNTINFOACCOUNT# SALESMANNUM NETTERMS111111 10 110222222 Null 130 333333 30 NullSalesmanSNUM NAME10 Jim20 Dan30 SteveNETINFONTERMS NETDAYS110 10130 30Result111111 10 Jim 110 10222222 NULL NULL 130 30333333 20 Dan NULL Null |
 |
|
|
|
|