select * from Contragent as A join Ledger as B on B.VDTSC0 = A.Code or B.VKTSC0 = A.Code or B.VDTSC1 = A.Code where A.Code = ' *'