title: compare two datatables with multiple columns with a unique id
body: <p>I have written a program to compare two datatables with unique ids and create another datatable to insert certain columns which have the same id in common. I have demonstrated my requirement below. </p>
  
  <p>These are the tables that needs to be compared:</p>
  
  <p><img src="https://i.stack.imgur.com/vNuYS.jpg" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/hL1z1.jpg" alt="enter image description here"></p>
  
  <p>And i need the output as below</p>
  
  <p><img src="https://i.stack.imgur.com/GjFEb.png" alt="enter image description here"></p>
  
  <p>but i receive an empty table as the result. I cannot understand where have i gone wrong. Could you please help me on this. I have provided my coding below.Please not that quantity and input are two datatables</p>
  
  <pre><code>DataTable result = new DataTable();
  result.Columns.AddRange(new DataColumn[2] { new DataColumn("id"), new DataColumn("qty") });         
  
  
              foreach (DataRow row1 in input.Rows)
              {
                  foreach (DataRow row2 in quantity.Rows)
                  {
                      if (row1["id"].ToString() == row2["id"].ToString())
                      {
                          result.ImportRow(row2);
                      }
                      else
                      {
                          result.ImportRow(row1);
                      }
                  }
              }
  
          return result;
  </code></pre>