<div dir="ltr"><div><div>if i execute a query in mysql select dialprefix,rateinitial  from  cc_ratecard where  (dialprefix=&#39;001&#39; or dialprefix=&#39;00123&#39;)   ORDER BY LENGTH(dialprefix) DESC;<br><br></div>result<br></div>row1    |  001 |     0.01000 |<br><div>row22  | 00123         |     0.02000 |<br><br></div><div>and this is   lua code  <br><br>local rates = {}<br>local count = &quot;&quot;;<br><br>     assert(dbh:query(query, function(qrow)<br>        for key, val in pairs(qrow) do<br>            rates[key] = val<br>freeswitch.consoleLog(&quot;INFO&quot;,&quot;    rates   :&quot;..key.. &quot;..=&quot;..val..&quot; \n&quot;)<br>        end<br>count = qrow.count;<br>        end))<br><br></div><div>questios  is <br>1 how to select 2nd row from result  ? <br></div><div>2 how to count total rows   ?<br></div><div>3 how to print all 2 rows in console   ?<br><br></div><div>any suggestios wellcome<br></div></div>