sql server - SQL condition in join statement -


i have use conditional statement in join (sql server)

select * inner join b on a.id = b.id 

if b.id null or b.id = '' should a.id2 = b.id2 instead of a.id = b.id

is correct if this:

   select * inner join b on      (b.id not null , b.id <> '' , a.id = b.id) or     ((b.id null or b.id = '') , a.id2 = b.id2) 

i think not best way solve problem, useful, simple:

select * inner join b  on a.id = b.id union  select * inner join b  on a.id2 = b.id2  b.id null or b.id = '' 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -