[Freeswitch-users] how to select 2nd row of sql query result in lua

Shabbir abbasi shabbirabbasi92 at gmail.com
Sat Dec 6 08:31:33 MSK 2014


if i execute a query in mysql select dialprefix,rateinitial  from
cc_ratecard where  (dialprefix='001' or dialprefix='00123')   ORDER BY
LENGTH(dialprefix) DESC;

result
row1    |  001 |     0.01000 |
row22  | 00123         |     0.02000 |

and this is   lua code

local rates = {}
local count = "";

     assert(dbh:query(query, function(qrow)
        for key, val in pairs(qrow) do
            rates[key] = val
freeswitch.consoleLog("INFO","    rates   :"..key.. "..="..val.." \n")
        end
count = qrow.count;
        end))

questios  is
1 how to select 2nd row from result  ?
2 how to count total rows   ?
3 how to print all 2 rows in console   ?

any suggestios wellcome
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20141206/9f181130/attachment.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list