title: combine one to more tables and get the values
body: <p>I have created insert query for combining one to more tables and take values into single.</p>
  <p><strong>Table 1:</strong></p>
  <p><strong>CandidateQualifications:</strong></p>
  <ul>
  <li>Id</li>
  <li>CandidateId</li>
  <li>DegreeId</li>
  <li>Specialization</li>
  </ul>
  <p><strong>Table 2:</strong></p>
  <p>UG_list</p>
  <ul>
  <li>Id</li>
  <li>Ugname</li>
  </ul>
  <p><strong>Table 3:</strong></p>
  <p>PG_list</p>
  <ul>
  <li>Id</li>
  <li>pgname</li>
  </ul>
  <p><strong>Table 4:</strong></p>
  <p>Docorate_List</p>
  <ul>
  <li>Id</li>
  <li>Ugname</li>
  </ul>
  <p>These all tables id is called to follow table,</p>
  <p><strong>CandidateDetails</strong></p>
  <ul>
  <li>Qualification</li>
  <li>Postgraduation</li>
  <li>doctorate</li>
  </ul>
  <p>It shows separate degrees in this candidatedetails table. when i use follow query i get only qualification values. others are eliminated. so if 3 degrees is there means candidateid shows 3 times. but only one time it show.</p>
  <p>My query is,</p>
  <pre><code>SELECT top(50) 'INSERT INTO CandidateQualifications(candidateId,DegreeId,specialization) VALUES('+
   Cast(c.CandidateID as varchar(50))+',''' +
   ISNULL(Cast(Coalesce(u.Id,p.Id,d.Id)as varchar(50)),'NULL')+','+
   IsNull(''''+c.ugspecification+'''', 'NULL')+')'
    FROM  candidatedetails as c
    LEFT join UG_List As u ON c.qualification=u.UGName
    LEFT join PG_List As p ON c.PostGraduation=p.PGName
    LEFT join Docorate_List As d ON c.Doctorate=d.Doctorate
  </code></pre>
  <p><strong>Result set</strong></p>
  <pre><code>INSERT INTO CandidateQualifications(candidateId,DegreeId,specialization) VALUES(2,'38,'Hotel Management')
  
  INSERT INTO CandidateQualifications(candidateId,DegreeId,specialization) VALUES(3,'17,'HMCT (Hotel Management&amp; Catering technology)')
  </code></pre>
  <p>Please help me anyone to come out this problem?</p>