title: For Loop in R yielding fewer values
body: <p>I have the following for loop in R to extract data from 4 My SQL tables. The dataframe length refers to the </p>
  
  <pre><code>     for (i in length(dataframe)){
  
       sql1 &lt;- paste("SELECT T.TenantLookupID, T.TenantShortCode, 
           B.BusinessUnitShortCode, C.CampaignShortCode
              from TenantLookup AS T
              JOIN BusinessUnitLookup AS B ON T.TenantLookupID = B.TenantLookupID
              JOIN CampaignLookup AS C ON C.TenantLookupID = B.TenantLookupID 
              where T.TenantID = '611c5d1c_f0bc_4bd4_b1c1_f6800d50fc34' AND B.BusinessUnitID = 0
              AND C.CampaignID =", i,sep="")
  
        dataframe2&lt;-dbGetQuery(jobdbconn, sql1)}
  </code></pre>
  
  <p>The code should yield 30 values 
  However it yields far fewer values. Can Someone suggest a solution</p>
  
  <pre><code>    TenantLookupID TenantShortCode BusinessUnitShortCode CampaignShortCode
      1            572             NOn                     w               uvn
      2            572             NOn                     w               Mxc
      3            572             NOn                     w               W0H
      4            572             NOn                     w               qr5
      5            572             NOn                     w               ABy
  </code></pre>
  
  <p>The format is right but at the number is far lesser than expected</p>