How To Access An Element From A Table Within A Table?

Hi!
This is my code:

local function getSubKat( n )     local sk = {}     if n ~= nil then         for row in db:nrows("SELECT  \* FROM Subkat WHERE hkid = '"..n.."' ORDER BY skid") do             -- create table at next available array index             local val =              {                 skid = row.skid,                 skname = row.skname             }             table.insert(sk, val)         end     end     return sk end for row in db:nrows("SELECT  \* FROM Mainkat ORDER BY hkname") do     -- create table at next available array index     local val =     {         hkid = row.hkid,         hkname = row.hkname,         skat = getSubKat( hkid )      }     table.insert(hk, val)     print(getSubKat( row.hkid )[1].skname) --Returns every first post in #sk where hkid = row.hkid end print(hk[1].skat[1].skname) --Returns an error. "attempt to index field '?' (a nil value)"

How do I do to get for example element .skname from element .skat in hk?

    local val =     {         hkid = row.hkid,         hkname = row.hkname,         skat = getSubKat( row.hkid )      }

Silly me. Thanks man! :smiley:

    local val =     {         hkid = row.hkid,         hkname = row.hkname,         skat = getSubKat( row.hkid )      }

Silly me. Thanks man! :smiley: