sql - How to only pull data from table 1 if table 2 also have data -


my problem is, have 2 tables using shipping , happening. if ca.addr_1 has data fine if there data in c.addr_2 show it. , want if ca.addr has data on line use if lines null use c.addr.

co.ship_to_addr_no addr_no, isnull(ca.name, c.name) name, isnull(ca.addr_1, c.addr_1) addr_1, isnull(ca.addr_2, c.addr_2) addr_2, isnull(ca.addr_3, c.addr_3) addr_3, isnull(ca.city, c.city) city,  isnull(ca.state, c.state) state, isnull(ca.zipcode, c.zipcode) zipcode, isnull(ca.country, c.country) country,  

case when should allow need.

case when ca.addr1 null , ca.addr_2 null , ca.addr_3 null c.addr else when .... 

you can add in many variations using else when need account whatever permutation of address results want select.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -