Can't select single row in table - when table is based on Joined SQL Query

Hi
I'm building an app that has several Retool tables. Some are from SQL imports from a single table, others from SQL join queries, others the result sets of API calls.

For the ones based on a single SQL query, I can select a single row, and edit if required. See below:

However, for tables based on joined SQL queries, I have the same Row Selection settings, but clicking anywhere in the table selects all rows, and I'm not able to edit. See below:

Is there another setting I'm missing, or am I not able to select if the data shown is joined?

End goal is for a user to be able to select rows in a checkbox (don't show up in ss sorry), then perform further actions for those rows selected.

I'm wondering - do I need to save the results of my joined query to a DB table firs then select from the single table?

Note the same thing seems true for not being able to select a row where the table is presenting {{data}} from an API calling JS script

Any guidance much appreciated!

Nick

Hey @nickaus!

Do you have a primary key column set for your table? Selection typically happens based on primary key, so if you have multiple rows with the same primary key, they'll be selected together:

In the case where the column specified as your primary key column isn't present in any of your rows all the rows functionally have the same key (undefined) so they all get selected together:

The row selection is set to "Single" in both of the examples above!

Let me know if that's not the case!

Hi @Kabirdas
Thanks for replying! :slight_smile:

That query is joining across 3 tables (basically team, issues and timelogs ) -each has a PK. But not sure if there's a way to 'specify' a key for the result set.

I worked around this by inserting the results of the query above into a summary table, then loading the results of that to a front-end table, where there is a pk and user can perform the actions (just settinga checkbox, which marks it for further processing).

Thanks for the tip though. I did notice this behaviour when I was working on something else that reads/writes to Sheets. If duplicates are entered in the Sheets Col specified as the PK, then I can no longer select an individual row in the table. I tried the method suggested here, but also ended up using a JS approach to prevent duplicates. In my case I created a basic function:

var siteslist = sites.data;
var newSite = newSiteURL.value;
if (siteslist.find(e => e.url === newSite)){
  return false
}
else {
  return true
}

I then trigger this script as an Event Handler on the input for newSiteURL text field 'on Change' with debounce set at 2000. I conditionally disable the 'Submit' button if the new site is a dup.

Thanks again!
Nick