Fetch related table data from row click

Totally new to retool and liking what i am seeing so far.
I am trying to pull related records from a table to show in a datatable2 from getting the id of a record in datatable1.
I set up a new query that would run when the row is clicked that gets the id of the row ({{datatable.selectedrowkey}} and then passed that into a sql query:
select * from shifts where idContractor = {{datatable.selectedrowkey}}
I get an error in the console that column idContractor doesn't exist. Am i not able to hop able searches like this?
Thanks in advance,
Jesse

Hi @jrobgk1 Welcome to Retool!

Hmm I believe you'll need to put double quotes around idContractor since it has an uppercase letter in it:

Also, selectedRowKey likely needs a camel case - not sure how you have it typed out in the query editor.

If it's still not working, I'd recommend 1) hardcoding the value instead of using {{datatable.selectedrowkey}} to be sure the query works and 2) sending us a screenshot of the query