I'm trying to display the percentage value as a default value in the web application, which is retrieved from the database by ID. However, I'm facing an issue where it displays the value of the ID in the first row.
My sql code(query1) :
SELECT
*
FROM
CLIENT.EntryCategory
WHERE
CategoryID = {{ editableText2.label.substring(0,2) }};
default value for each row: {{query1.data.percentage}}
the value of editableText2.label.substring(0,2) should be in every row different but it isn't.
I tried it with 'I' but it didn't work because He displayed the result only in sequence and not next to the correct element . I Solved the Problem with a JS transformer:
I compared 2 Object with each other and added them to an object.
Example
let result = {};
let count = {{ checkboxGroup3.value }}
let object = {{query36.data}}; [Event.ID,Event.Name]
let object1 = {{query37.data}};[Event.ID,Event.Percentage]
for (let i = 0; i < count.length; i++) {
for (let j = 0; j < count.length; j++) {
if (object.ID[i] === object1.EventID[j]) {
const key = object.ID[i];
const value = object1.Percentage[j];
result[key] = value;
}
}
}
return result;
However, I am still open to better solutions, as I am concerned that this solution may slow down my app
I took a look at your code and wanted to clarify your use case! It sounds like you have data coming from two different tables and want to match the data by ID and EventID? If so, would writing this logic using SQL JOINs work instead? It's generally better to write this sort of logic at the server level rather than at the client level (basically, you want to pull as little data into Retool/the browser as possible so your SQL queries should do as much pre-filtering as they can).
Sadly. there is no possibility ( I think) to write this logic in SQL because the data coming from 2 different Database sources. the first one is from a Mysql DB and the second one MSSQL DB