Data.jsw functions working on preview mode but not on live mode. HELP

I have a simple function that always works fine in PREVIEW but it never shows results in LIVE. What am I missing?

Data.jsw code

export async function getCommissions() {
    try {
        let mySQL = 'SELECT Agent.commissionsDisplayName, Agent.displayName, Commissions._id, '
        mySQL +=    'Commissions.date, Commissions.payeeEmail, Agent.email, Commissions.policy, '
        mySQL +=    'Commissions.clientFirstName, Commissions.clientLastName, Commissions.type, Commissions.amount '
        mySQL +=    'FROM Commissions '
        
        mySQL +=     'INNER JOIN Agent ON Commissions.payeeEmail = Agent.email '

        const results = await sql(mySQL);
        return results.payload.data.rows;
     
    } 
    catch (error) {
        console.error(error);
    }
} 

Page Code:

async function doSearch()
{
let myResults = await getCommissions()
$w(“#tableResults”).rows = myResults;
}

Check DATABASE + BACKEND-PERMISSIONS first.
Set them to lowest level to ensure, that this is not the missing point.

Thanks, tried that but no good. It all works properly using wixData… I am converting (well, trying to convert) wixData over to SQL. So the issue is with the SQL implementation.

Maybe it will be easier to learn how to do inner joins with WixData? Can’t say I really have a clue… SQL is easy and I have done it for years.

What exactly do you mean by…

Maybe it will be easier to learn how to do inner joins with WixData?

What do you want to → “join” exactly?

Perhaps a little example?

Look at my SQL. I would not know how to do something similar with wixData. I need to join data from 2 tables/collections. Thank you!

let mySQL = 'SELECT Agent.commissionsDisplayName, Agent.displayName, Commissions._id, '
        mySQL +=    'Commissions.date, Commissions.payeeEmail, Agent.email, Commissions.policy, '
        mySQL +=    'Commissions.clientFirstName, Commissions.clientLastName, Commissions.type, Commissions.amount '
        mySQL +=    'FROM Commissions '
        mySQL +=     'INNER JOIN Agent ON Commissions.payeeEmail = Agent.email 

Take a look here…

http://www.silota.com/docs/recipes/sql-join-tutorial-javascript-examples.html

Here some more info for you…

Here some more…

Here some more…