Simple SQL Join Query of Retool Database

Hi there!

It's been a while since I've used SQL so I'm probably making a simple mistake here:

I'm trying to write a query to a Retool database to display the SKU image, which is stored in a rental_skus table, in a list with the items in an order, which are stored in an orders_skus table.

select orders_skus.order_sku, orders_skus.order_id, orders_skus.status, rental_skus.sku, rental_skus.image_url
from orders_skus
left outer join rental_skus
on order_skus.order_sku = rental_skus.sku
where orders_skus.order_id = {{collectionView1.selectedItem.short_id}} 
and orders_skus.status='unpicked';

I can select orders from the orders_skus table fine, including the conditions, but as soon as I add a join I get a 400 error. I've tried using other joins but with no luck?

Grateful for any help!


Hey @danaio!

Would you mind posting a screenshot of the exact error you're seeing?

Hi Kabirdas,

Oh boy that isn't particularly helpful is it :sweat:

It might be worth trying to hardcode a value for {{collectionView1.selectedItem.short_id}} to see if that changes anything. I'd also be interested to see maximal working queries for each of the tables separately, e.g. do

select orders_skus.order_sku, orders_skus.order_id, orders_skus.status
from orders_skus
where orders_skus.order_id = {{collectionView1.selectedItem.short_id}} 
and orders_skus.status='unpicked';


select rental_skus.sku, rental_skus.image_url
from rental_skus;