Insert multiple checkbox value from webform into table I created:

a webform named Test Number checkboxes
checkboxes named Number with values one, two and
three using Form Builder
a table named checkbox_check


Aim: When the webform is submitted, the values selected are placed in a string and saved into the table. Example: If &quot;one&quot; and &quot;two&quot; are selected from the checkboxes, they will be saved like &quot;one,two&quot; in the table when the webform is submitted.
The table name is checkbox_check with field Number (Vachar 11)
EDITED: I just added these codes within the function webform_webform_submission_insert($node, $submission) from the webform.module file in my drupal project:
$accessnode=$node-&gt;nid;
if($accessnode==11)// the **Test Number checkboxes** webform containing the checkboxes
{       
    $lastestSub=db_query(&quot;SELECT MAX(sid) FROM {webform_submitted_data}&quot;)-&gt;fetchField(); //retrieving the highest number of sid which is the lastest submission
    $selectedData=db_query(&quot;SELECT data FROM {webform_submitted_data} WHERE nid = :nid AND cid =:cid AND sid= :sid&quot;,array(':nid'=&gt;$accessnode, ':cid' =&gt; 1, 'sid'=&gt;$lastestSub))-&gt;fetchAll();
    
    
    $text='';// This will be used to concatenate the different values into a string and placed in the table afterwards
    foreach($selectedData as $valD)
    {
            $text=$text.$valD.&quot;,&quot;;  
    }
        db_insert('checkbox_check')
        -&gt;fields(array(
    
        'Number' =&gt; $text, 
        ))
        -&gt;execute();
        
}

When I submitted the webform, I got this error message:

Can you guys help me with this?
It works if I replace these codes:

$selectedData=db_query("SELECT data FROM {webform_submitted_data} WHERE nid = :nid AND cid =:cid AND sid= :sid",array(':nid'=&gt;$accessnode, ':cid' =&gt; 1, 'sid'=&gt;$lastestSub))-&gt;fetchAll();


by this:

$selectedData=db_query("SELECT data FROM {webform_submitted_data} WHERE nid = :nid AND cid =:cid AND sid= :sid",array(':nid'=&gt;$accessnode, ':cid' =&gt; 1, 'sid'=&gt;$lastestSub))-&gt;fetchCol();