Work out if a string is "fieldname" or "tablename.fieldname", and assign variables
Assuming that field always gets the value of the last part of dbFieldEntries you could do:

field = dbEntryEntries[ dbFieldEntries.length - 1 ];
if ( dbFieldEntries.length &gt; 1 ) {
  table = dbEntryEntries[ 0 ];
}


Besides this, s is a bad variable name.