Priyanka Singh

Priyanka Singh

  • 667
  • 1.4k
  • 660.1k

Join two tables in sql server

Oct 17 2019 2:28 AM
I have to fetch a value from two tables as a single result. But I am unable to join it. Please help me.
 
  1. select Constituent_Indices from ListingInfo A where comp_code='C0000578' --tbl one  
  2.   
  3. --table two  
  4. DECLARE @index_name VARCHAR(500)      
  5. SELECT @index_name = COALESCE(@index_name + ', ''') + index_name   
  6. FROM MasterTables..indices_master B where comp_code='C0000578'    
  7. SELECT LEFT(RTRIM(@index_name), ( LEN(RTRIM(@index_name)))) as Constituent_Indices   
 

Answers (1)