Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Left Join with 2 references

$
0
0
If this has been asked, please excuse me. I need to join 2 tables but the join needs to account for 2 seperate columns. for example:select a. typea. prod_codea. prod_typeb. divisionfrom table1 a left join table2 bon a. prod_code = b. prod_codeand a. prod_type = b. prod_typeThe issue is that you may have only the [i]prod_code[/i] or [i]prod_type[/i] and null value for the other in table1.Ideally I want it to check for both then if 1 isn't available then it draws the [i]division[/i] of the available. having both or one or the other determines the [i]division[/i] it falls under. Is this possible? Thanks in advance.edit for spelling...

Viewing all articles
Browse latest Browse all 3145

Trending Articles