Use Table Cell Value in Query Where Clause

I am trying to use the value of a table cell in a WHERE clause:

SELECT SUM("invoiceTotal") AS lines_total, SUM("balanceOwed") AS lines_balance FROM "invoicesToCustomer" WHERE "invoiceNumber" = '{{invoicesTable.selectedRow.invoiceNumber}}'

I get the error:

bind message supplies 1 parameters, but prepared statement "" requires 0

I know this is a simple problem, but Googling and the Forum didn't reveal an answer.

Thanks.

I found the solution, although I don't understand why. :slight_smile:

So, the correct query is:

SELECT SUM("invoiceTotal") AS lines_total, SUM("balanceOwed") AS lines_balance FROM "invoicesToCustomer" WHERE "invoiceNumber" LIKE {{'%' + invoicesTable.selectedRow.invoiceNumber + '%'}};

Hello @haj,

Just curious, does this also work:

SELECT SUM("invoiceTotal") AS lines_total, SUM("balanceOwed") AS lines_balance FROM "invoicesToCustomer" WHERE "invoiceNumber" LIKE "%{{invoicesTable.selectedRow.invoiceNumber}}%";

Patrick

@PatrickMast , no that won’t work, the part between {{}} is already being converted to a string with surrounding double quotes. The result would be “%”string”%”.
The way @haj did it is indeed the correct way to do this.

1 Like

@PatrickMast. I tried your way first. @mbruijnpff is correct. Won't work.

1 Like